TASTy reader: Accessing opaque type with type param causes `NoSuchMethodError`
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
Did you enable -Ytasty-reader? I don't recall offhand if opaque types are in the supported subset of Scala 3.
@SethTisue There's a repo with github action to demo the error. https://github.com/jilen/scala2-opaque-error/actions/runs/12455416725/job/34767789185#step:4:27
@bishabosha is this a bug, or expected behavior?
I wrote it such that it is replaced with its rhs at erasure - I might not have considered substitutions
transferred to scala/bug since it seems likely the issue is on the Scala 2 side