Open
Description
Compiler version
3.5.2 and other versions
Minimized code
https://github.com/jilen/scala2-opaque-error
file1 define opaque type (scala3)
object Alias {
opaque type Of[X] <: X = X
def of[X](i: X): Alias.Of[X] = i
}
class Foo(id: Alias.Of[Long])
file2, use opaque type (scala 2.13)
object FooApp {
def main(args: Array[String]) = {
val f = new Foo(Alias.of(1L))
println(f)
}
}
Output
Compiles fine, run fail with
[113] Exception in thread "main" java.lang.NoSuchMethodError: 'void lib.Foo.<init>(java.lang.Object)'
[113] apat app.FooApp$.main(App.scala:8)
[113] 13at app.FooApp.main(App.scala)
Expectation
Should run without exception