Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jadenPete opened this issue May 14, 2025 · 1 comment
Open
Labels

Comments

@jadenPete
Copy link

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.

@jadenPete jadenPete added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels May 14, 2025
@jadenPete jadenPete changed the title Certain value classes compiled with Scala 2 can't be used with Scala 3 Some value classes compiled with Scala 2 can't be used with Scala 3 May 14, 2025
@jadenPete jadenPete changed the title Some value classes compiled with Scala 2 can't be used with Scala 3 Certain value classes compiled with Scala 2 can't be used with Scala 3 May 14, 2025
@som-snytt
Copy link
Contributor

Likely
#22177
#22525

I forgot my comment about a missing bridge; or is it just how the result is erased?

@Gedochao Gedochao added compat:scala2 area:value-classes Issues tied to value classes. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants