Skip to content

TASTy reader: Accessing opaque type with type param causes NoSuchMethodError #13072

Open
@jilen

Description

@jilen

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions