Skip to content

Certain value classes compiled with Scala 2 can't be used with Scala 3 #23163

Open
@jadenPete

Description

@jadenPete

Compiler version

2.13.16 and 3.6.3

Minimized code

  1. Compile the following code with Scala 2:
trait Tag

class Tagger[T](val value: T) extends AnyVal {
  def withTag: T & Tag = ???
}
  1. Compile the following code with Scala 3:
object Main {
  def main(arguments: Array[String]): Unit = {
    val x = 2

    println(new Tagger(x).withTag)
  }
}

Output

Run the Scala 3 code and observe the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: 'Tag Tagger$.withTag$extension(java.lang.Object)'
	at Main$.main(Scala3.scala:5)
	at Main.main(Scala3.scala)

Expectation

That NoSuchMethodError wouldn't be thrown.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions