We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
object inlinetest: 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
Disassemblied (via CFR) output of test
public int test() { return BoxesRunTime.unboxToInt((Object)((JFunction1.mcII.sp & Serializable)(JFunction1.mcII.sp & Serializable)i -> { int x = 1; return 2 + x; }).apply((Object)BoxesRunTime.boxToInteger((int)2))) + 3; }
The result should not contain any lambda.
Manually inlining inline1 produces the intended result
inline1
def test: Int = inline2(i => 2 + 1)
it gets properly inlined
public int test() { return 6; }
The text was updated successfully, but these errors were encountered:
I noticed this as well. We only inline TermRefs but not constants.
https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala#L63-L70
Sorry, something went wrong.
Actually it is this one
https://github.com/lampepfl/dotty/blob/a6acaa9f95ffa59dd736f22dbb839759f7c85c63/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L919
Add beta-reduction regression test
d986c45
Fixes scala#9456
nicolasstucki
Successfully merging a pull request may close this issue.
Minimized code
Output
Disassemblied (via CFR) output of test
Expectation
The result should not contain any lambda.
Notes
Manually inlining
inline1
produces the intended resultit gets properly inlined
The text was updated successfully, but these errors were encountered: