Closed
Description
We have a problem stopping us from updating to Scala 3, since we use Graalvm native-image. Native image uses a lot reflection when building and the byte code generated by Scala 3 seems to be invalid in some edge cases. For us the error happens in the skunk database library typelevel/skunk#623. I've finally been able to create a small reproducer, I think.
It breaks when Class.getEnclosingMethod() is called for the check() method below.
Compiler version
3.3.1
Minimized code
trait TA {
def tb(): TB
}
trait TB {
def check(): Unit
}
object A {
def a(): TA =
new TA {
override def tb(): TB =
Seq(1).map { _ =>
new TB {
override def check(): Unit =
println(this.getClass.getEnclosingMethod()) // InternalError thrown here
}
}.head
}
}
@main
def main() = {
A.a().tb().check()
}
Output
InternalError
Expectation
The enclosing method should be returned