Closed
Description
This was initially reported in scala/bug#11740, then fixed in scala/scala#8451, but never ported to Dotty (perhaps because the changes collide a little without the new pattern matching).
I would expect the following to compile into a lookupswitch
based on the hashCode
of the cases, as it does in Scala 2 (and as Java, Kotlin, etc. also do).
def testMatch(s: String): Int = (s: @switch) match {
case "S0" => 123
case "S1" => 121
case "S2" => 193
case "S3" => 223
case "S4" => 423
case "S5" => 153
case "S6" => 143
case "S7" => 133
}
To further confuse the story, this comment from the JS codgen appears to suggest that at some point the Scala.js backend would've received and emitted a switch
over strings (although I can't reproduce that behavior, even on Scala 2 and with @switch
supposedly claiming a switch will be emitted).