Skip to content

Compiler crash on inline method with array creation with implicitly summoned arg #6015

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
milessabin opened this issue Mar 4, 2019 · 1 comment

Comments

@milessabin
Copy link
Contributor

The following crashes the compiler during code generation,

import scala.compiletime._

object Test {
  implicit val i: Int = 23

  inline def foo() = {
    Array[Int](implicitly[Int])
  }

  foo()
}
Unexpected tree in genLoad: Inlined(Ident(DottyPredef$),List(),Apply(Ident(i),List()))/class dotty.tools.dotc.ast.Trees$Inlined at: <108..123>
java.lang.RuntimeException: Unexpected tree in genLoad: Inlined(Ident(DottyPredef$),List(),Apply(Ident(i),List()))/class dotty.tools.dotc.ast.Trees$Inlined at: <108..123>
        at dotty.tools.backend.jvm.DottyBackendInterface.abort(DottyBackendInterface.scala:390)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:431)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genArray(BCodeBodyBuilder.scala:842)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genArrayValue(BCodeBodyBuilder.scala:827)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:420)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1(BCodeBodyBuilder.scala:1051)
        at dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.$anonfun$genLoadArguments$1$adapted(BCodeBodyBuilder.scala:1051)
        at scala.collection.immutable.List.foreach(List.scala:392)
...

The problem goes away if the implicitly summoned argument is assigned to a val first, or if the array creation is replaced by a call to a vanilla polymorphic method.

@odersky
Copy link
Contributor

odersky commented Mar 18, 2019

dropInlined fails to remove an inlined in the SeqLiteral. I tried to fix it but I could not understand the logic in dropInlined#transformed to do this with confidence. It would help if the transformed method was better documented. What does it do exactly? Why treat the cases it does and not others?

nicolasstucki added a commit that referenced this issue Mar 20, 2019
Fix #6015: Transform inner missing trees
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

3 participants