@@ -983,26 +983,38 @@ class TestBCode extends DottyBytecodeTest {
983
983
|class Foo {
984
984
| val FreshApprox: ApproxState = new ApproxState(4)
985
985
| var approx: ApproxState = FreshApprox
986
- | def meth: Boolean = approx == FreshApprox
986
+ | def meth1: Boolean = approx == FreshApprox
987
+ | def meth2: Boolean = (new ApproxState(4): ApproxState) == FreshApprox
987
988
|}
988
989
""" .stripMargin
989
990
990
991
checkBCode(source) { dir =>
991
992
val clsIn = dir.lookupName(" Foo.class" , directory = false ).input
992
993
val clsNode = loadClassNode(clsIn)
993
- val meth = getMethod(clsNode, " meth" )
994
+ val meth1 = getMethod(clsNode, " meth1" )
995
+ val meth2 = getMethod(clsNode, " meth2" )
996
+ val instructions1 = instructionsFromMethod(meth1)
997
+ val instructions2 = instructionsFromMethod(meth2)
994
998
995
- val instructions = instructionsFromMethod(meth)
996
999
val isFrameLine = (x : Instruction ) => x.isInstanceOf [FrameEntry ] || x.isInstanceOf [LineNumber ]
1000
+
997
1001
// No allocations of ApproxState
998
- assertSameCode(instructions.filterNot(isFrameLine), List (
1002
+
1003
+ assertSameCode(instructions1.filterNot(isFrameLine), List (
999
1004
VarOp (ALOAD , 0 ), Invoke (INVOKEVIRTUAL , " Foo" , " approx" , " ()I" , false ),
1000
1005
VarOp (ALOAD , 0 ), Invoke (INVOKEVIRTUAL , " Foo" , " FreshApprox" , " ()I" , false ),
1001
1006
Jump (IF_ICMPNE , Label (7 )), Op (ICONST_1 ),
1002
1007
Jump (GOTO , Label (10 )),
1003
1008
Label (7 ), Op (ICONST_0 ),
1004
- Label (10 ), Op (IRETURN )
1005
- ))
1009
+ Label (10 ), Op (IRETURN )))
1010
+
1011
+ assertSameCode(instructions2.filterNot(isFrameLine), List (
1012
+ Op (ICONST_4 ),
1013
+ VarOp (ALOAD , 0 ), Invoke (INVOKEVIRTUAL , " Foo" , " FreshApprox" , " ()I" , false ),
1014
+ Jump (IF_ICMPNE , Label (6 )), Op (ICONST_1 ),
1015
+ Jump (GOTO , Label (9 )),
1016
+ Label (6 ), Op (ICONST_0 ),
1017
+ Label (9 ), Op (IRETURN )))
1006
1018
}
1007
1019
}
1008
1020
}
0 commit comments