File tree 1 file changed +39
-0
lines changed
compiler/test/dotty/tools/backend/jvm
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -281,4 +281,43 @@ class InlineBytecodeTests extends DottyBytecodeTest {
281
281
282
282
}
283
283
}
284
+
285
+ // Testing that a is not boxed
286
+ @ Test def i4522 = {
287
+ val source = """ class Foo {
288
+ | def test: Int = {
289
+ | var a = 10
290
+ |
291
+ | rewrite def f() = {
292
+ | a += 1
293
+ | }
294
+ |
295
+ | f()
296
+ | a
297
+ | }
298
+ |}
299
+ """ .stripMargin
300
+
301
+ checkBCode(source) { dir =>
302
+ val clsIn = dir.lookupName(" Foo.class" , directory = false ).input
303
+ val clsNode = loadClassNode(clsIn)
304
+
305
+ val fun = getMethod(clsNode, " test" )
306
+ val instructions = instructionsFromMethod(fun)
307
+ val expected =
308
+ List (
309
+ IntOp (BIPUSH , 10 )
310
+ , VarOp (ISTORE , 1 )
311
+ , VarOp (ILOAD , 1 )
312
+ , Op (ICONST_1 )
313
+ , Op (IADD )
314
+ , VarOp (ISTORE , 1 )
315
+ , VarOp (ILOAD , 1 )
316
+ , Op (IRETURN )
317
+ )
318
+ assert(instructions == expected,
319
+ " `f` was not properly inlined in `fun`\n " + diffInstructions(instructions, expected))
320
+
321
+ }
322
+ }
284
323
}
You can’t perform that action at this time.
0 commit comments