Skip to content

Add beta-reduction regression test #11113

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 1 commit into from
Jan 13, 2021
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
33 changes: 33 additions & 0 deletions compiler/test/dotty/tools/backend/jvm/InlineBytecodeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -582,4 +582,37 @@ class InlineBytecodeTests extends DottyBytecodeTest {

}
}

@Test def i9456 = {
val source = """class Foo {
| def test: Int = inline2(inline1(2.+))
|
| inline def inline1(inline f: Int => Int): Int => Int = i => f(1)
|
| inline def inline2(inline f: Int => Int): Int = f(2) + 3
|}
""".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 = // TODO room for constant folding
List(
Op(ICONST_1),
VarOp(ISTORE, 1),
Op(ICONST_2),
VarOp(ILOAD, 1),
Op(IADD),
Op(ICONST_3),
Op(IADD),
Op(IRETURN),
)
assert(instructions == expected,
"`f` was not properly inlined in `fun`\n" + diffInstructions(instructions, expected))

}
}
}