Skip to content

Inlined methods of type Unit produce unnesesary code #9246

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

Closed
edolgy opened this issue Jun 25, 2020 · 1 comment · Fixed by #9263
Closed

Inlined methods of type Unit produce unnesesary code #9246

edolgy opened this issue Jun 25, 2020 · 1 comment · Fixed by #9263

Comments

@edolgy
Copy link

edolgy commented Jun 25, 2020

inline def check(v:Double): Unit = if(v==0) throw new Exception()

inline def divide(v: Double, d: Double): Double = { check(d); v / d }

def run =  divide(10,2)
// Java decompiled method run
public double run() {
  BoxedUnit var10000 = BoxedUnit.UNIT;
  return 5.0D;
}

Expectation

The BoxedUnit type variable is very annoying when trying to optimize inlined code

@bishabosha
Copy link
Member

thanks for the report, I will link this to #6800, it seems this is the simpler case

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 30, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 30, 2020
@nicolasstucki nicolasstucki linked a pull request Jun 30, 2020 that will close this issue
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 30, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 1, 2020
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jul 1, 2020
nicolasstucki added a commit that referenced this issue Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants