scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Matching over constants of a value class wrapping a value type doesn't emit `switch`. #12927

Open noresttherein opened 5 months ago

noresttherein commented 5 months ago

Reproduction steps

Scala version: 2.13.11

    class Wrapper(val self :Int) extends AnyVal

    final val One = new Wrapper(1)
    final val Two = new Wrapper(2)

    (One :Wrapper @switch) match {
        case One =>
        case Two =>
        case _ =>
    }

Problem

Compiler warns:

could not emit switch for @switch annotated match
    (One :Wrapper @switch) match {

I may not understand something fully, but there doesn't seem to be a reason for this not to work.