Closed
Description
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.