@@ -320,4 +320,40 @@ class InlineBytecodeTests extends DottyBytecodeTest {
320
320
321
321
}
322
322
}
323
+
324
+ @ Test def i6375 = {
325
+ val source = """ class Test:
326
+ | given Int = 0
327
+ | def f(): Int ?=> Boolean = true : (Int ?=> Boolean)
328
+ | inline def g(): Int ?=> Boolean = true
329
+ | def test = g()
330
+ """ .stripMargin
331
+
332
+ checkBCode(source) { dir =>
333
+ val clsIn = dir.lookupName(" Test.class" , directory = false ).input
334
+ val clsNode = loadClassNode(clsIn)
335
+
336
+ val fun = getMethod(clsNode, " test" )
337
+ val instructions = instructionsFromMethod(fun)
338
+ val expected =
339
+ List (
340
+ // Head tested separatly
341
+ VarOp (ALOAD , 0 ),
342
+ Invoke (INVOKEVIRTUAL , " Test" , " given_Int" , " ()I" , false ),
343
+ Invoke (INVOKESTATIC , " scala/runtime/BoxesRunTime" , " boxToInteger" , " (I)Ljava/lang/Integer;" , false ),
344
+ Invoke (INVOKEINTERFACE , " scala/Function1" , " apply" , " (Ljava/lang/Object;)Ljava/lang/Object;" , true ),
345
+ Invoke (INVOKESTATIC , " scala/runtime/BoxesRunTime" , " unboxToBoolean" , " (Ljava/lang/Object;)Z" , false ),
346
+ Op (IRETURN )
347
+ )
348
+
349
+ instructions.head match {
350
+ case InvokeDynamic (INVOKEDYNAMIC , " apply$mcZI$sp" , " ()Ldotty/runtime/function/JFunction1$mcZI$sp;" , _, _) =>
351
+ case _ => assert(false , " `g` was not properly inlined in `test`\n " )
352
+ }
353
+
354
+ assert(instructions.tail == expected,
355
+ " `fg was not properly inlined in `test`\n " + diffInstructions(instructions, expected))
356
+
357
+ }
358
+ }
323
359
}
0 commit comments