Skip to content

Fix #4522: Add a regression test #5060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,43 @@ class InlineBytecodeTests extends DottyBytecodeTest {

}
}

// Testing that a is not boxed
@Test def i4522 = {
val source = """class Foo {
| def test: Int = {
| var a = 10
|
| rewrite def f() = {
| a += 1
| }
|
| f()
| a
| }
|}
""".stripMargin

checkBCode(source) { dir =>
val clsIn = dir.lookupName("Foo.class", directory = false).input
val clsNode = loadClassNode(clsIn)

val fun = getMethod(clsNode, "test")
val instructions = instructionsFromMethod(fun)
val expected =
List(
IntOp(BIPUSH, 10)
, VarOp(ISTORE, 1)
, VarOp(ILOAD, 1)
, Op(ICONST_1)
, Op(IADD)
, VarOp(ISTORE, 1)
, VarOp(ILOAD, 1)
, Op(IRETURN)
)
assert(instructions == expected,
"`f` was not properly inlined in `fun`\n" + diffInstructions(instructions, expected))

}
}
}