-
Notifications
You must be signed in to change notification settings - Fork 22
Path generated for implicit conversion leads to NoSuchMethodError #13160
Copy link
Copy link
Open
scala/scala
#11215Description
Requires separate compilation
T.scala
trait T {
object i {
class C
private object C {
import scala.language.implicitConversions
implicit def c2i(a: C): Int = 42
}
}
}
object O {
def foo(x: Int): String = "hi"
}U.scala
object Test extends T {
def main(): Unit = {
println(O.foo(new i.C))
}
}➜ sandbox sc T.scala && sc U.scala && sr Test
> scala compile --server=false -S 2.13 -d . -release 8 T.scala
> scala compile --server=false -S 2.13 -d . -release 8 U.scala
> scala run -S 2.13 -cp . -M Test
Exception in thread "main" java.lang.NoSuchMethodError: 'T$i$C$ T$i$.T$i$$C()'
at Test$.main(U.scala:3)
at Test.main(U.scala)
An implicit conversion gets added in O.foo(new i.C) and we get O.foo(Test.this.i.C.c2i(new Test.this.i.C())). This code is not valid, the object C is not accessible.
In a later phase the compiler calls makeNotPrivate on the symbol for C, which results in the T$i$$C name being emitted.
Reactions are currently unavailable