-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Inefficient code generated for if used as statement #5750
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
Comments
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 19, 2019
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 19, 2019
odersky
added a commit
that referenced
this issue
Jan 20, 2019
Fix #5750: Type then part of If with no else part as Unit
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 21, 2019
This is an alternative fix for scala#5750
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 21, 2019
This is an alternative fix for scala#5750
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 21, 2019
This is an alternative fix for scala#5750
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 21, 2019
This is an alternative fix for scala#5750
allanrenucci
added a commit
to dotty-staging/dotty
that referenced
this issue
Jan 21, 2019
This is an alternative fix for scala#5750
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Given:
The generated code for
test
is:Which is basically equivalent to
val a = if (cond) doStuff() else BoxedUnit.UNIT; 1
. More efficient bytecode is generated if the if branch ends with()
:It shouldn't be too complicated to emit this for the original example too (either with a better analysis in the backend or with a tree transformation phase that adds the
()
to ifs that are not used as expression. Note that scalac seems to behave exactly like dotty here /cc @retronym @lrytzThe text was updated successfully, but these errors were encountered: