Skip to content

Backend crash when passing a field projection with a new at an inline method #6341

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
biboudis opened this issue Apr 18, 2019 · 2 comments
Closed

Comments

@biboudis
Copy link
Contributor

object Test {
  class Config(val t1: Int)

  inline def m(t2:Int) = t2

  m(new Config(3).t1)
}
Unexpected tree in genLoad: TypeTree[TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class Test$)),class Test$Config)]/class dotty.tools.dotc.ast.Trees$TypeTree at: <68..68>
java.lang.RuntimeException: Unexpected tree in genLoad: TypeTree[TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class Test$)),class Test$Config)]/class dotty.tools.dotc.ast.Trees$TypeTree at: <68..68>
        at dotty.tools.backend.jvm.DottyBackendInterface.abort(DottyBackendInterface.scala:390)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:433)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:263)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoadQualifier(BCodeBodyBuilder.scala:1012)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genNormalMethodCall$1(BCodeBodyBuilder.scala:784)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:816)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:339)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:83)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genBlock$1(BCodeBodyBuilder.scala:920)
...
@biboudis biboudis added this to the 0.15 Tech Preview milestone Apr 18, 2019
@biboudis biboudis self-assigned this Apr 18, 2019
@biboudis biboudis changed the title Backend crash when passing a field projection after a new at an inline method Backend crash when passing a field projection with a new at an inline method Apr 18, 2019
@biboudis
Copy link
Contributor Author

@odersky If I comment out this line in computeParamBindings https://github.com/lampepfl/dotty/blob/master/compiler/src/dotty/tools/dotc/typer/Inliner.scala#L288
the test above passes. This line matches new Config(3).t1 as a SingletonType of t1:

TermRef(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),module class Test$)),class Config),val t1)

Is this the correct SingletonType? Should it be considered even Singleton given that it has an unstable prefix? Should it have been just the ConstantType 3?

biboudis added a commit to dotty-staging/dotty that referenced this issue Apr 25, 2019
biboudis added a commit to dotty-staging/dotty that referenced this issue Apr 25, 2019
@odersky
Copy link
Contributor

odersky commented Apr 25, 2019

Thanks for the diagnostic, which was pinpointing the problem precisely!

biboudis added a commit that referenced this issue Apr 29, 2019
anatoliykmetyuk pushed a commit to dotty-staging/dotty that referenced this issue May 2, 2019
There is some confusion on terms that needs to be fixed.

Step 1: Make `SimplyPure apply to paths only.

The only point where it is used is in eta expansion to answer the question
whether in a partial application `f(e, _)` the expression `e` should be
lifted out, giving `{ val x = e; y => f(x, y) }` instead of `y => f(e, y)`.
With the change, closures and new expressions are never simply pure, so
are always lifted out. This can reduce the number of allocations, if the
lambda is applied several times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants