@@ -345,7 +345,7 @@ class InlineBytecodeTests extends DottyBytecodeTest {
345345 }
346346
347347 // Testing that a is not boxed
348- @ Test def i4522 = {
348+ @ Test def i4522 = {
349349 val source = """ class Foo {
350350 | def test: Int = {
351351 | var a = 10
@@ -480,7 +480,28 @@ class InlineBytecodeTests extends DottyBytecodeTest {
480480 val expected = List (Ldc (LDC , 5.0 ), Op (DRETURN ))
481481 assert(instructions == expected,
482482 " `divide` was not properly inlined in `test`\n " + diffInstructions(instructions, expected))
483+ }
484+ }
485+
486+ @ Test def finalVals = {
487+ val source = """ class Test:
488+ | final val a = 1 // should be inlined but not erased
489+ | inline val b = 2 // should be inlined and erased
490+ | def test: Int = a + b
491+ """ .stripMargin
492+
493+ checkBCode(source) { dir =>
494+ val clsIn = dir.lookupName(" Test.class" , directory = false ).input
495+ val clsNode = loadClassNode(clsIn)
496+
497+ val fun = getMethod(clsNode, " test" )
498+ val instructions = instructionsFromMethod(fun)
499+ val expected = List (Op (ICONST_3 ), Op (IRETURN ))
500+ assert(instructions == expected,
501+ " `a and b were not properly inlined in `test`\n " + diffInstructions(instructions, expected))
483502
503+ val methods = clsNode.methods.asScala.toList.map(_.name)
504+ assert(methods == List (" <init>" , " a" , " test" ), clsNode.methods.asScala.toList.map(_.name))
484505 }
485506 }
486507
0 commit comments