File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
compiler/test/dotty/tools/backend/jvm Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -582,4 +582,37 @@ class InlineBytecodeTests extends DottyBytecodeTest {
582582
583583 }
584584 }
585+
586+ @ Test def i9456 = {
587+ val source = """ class Foo {
588+ | def test: Int = inline2(inline1(2.+))
589+ |
590+ | inline def inline1(inline f: Int => Int): Int => Int = i => f(1)
591+ |
592+ | inline def inline2(inline f: Int => Int): Int = f(2) + 3
593+ |}
594+ """ .stripMargin
595+
596+ checkBCode(source) { dir =>
597+ val clsIn = dir.lookupName(" Foo.class" , directory = false ).input
598+ val clsNode = loadClassNode(clsIn)
599+
600+ val fun = getMethod(clsNode, " test" )
601+ val instructions = instructionsFromMethod(fun)
602+ val expected = // TODO room for constant folding
603+ List (
604+ Op (ICONST_1 ),
605+ VarOp (ISTORE , 1 ),
606+ Op (ICONST_2 ),
607+ VarOp (ILOAD , 1 ),
608+ Op (IADD ),
609+ Op (ICONST_3 ),
610+ Op (IADD ),
611+ Op (IRETURN ),
612+ )
613+ assert(instructions == expected,
614+ " `f` was not properly inlined in `fun`\n " + diffInstructions(instructions, expected))
615+
616+ }
617+ }
585618}
You can’t perform that action at this time.
0 commit comments