Closed as not planned
Description
Reproduction steps
Scala 2 version: 2.13.16
Scala 3 version: 3.6.3
- Compile the following code with Scala 3:
sealed trait Pet
case class Dog(name: String) extends Pet
case class Cat(name: String) extends Pet
- Compile the following code with Scala 2:
class PetPrinter {
def printPet(pet: Pet): Unit = println(
pet match {
case Dog(_) => "I'm a dog."
case Cat(_) => "I'm a cat."
},
)
}
- Observe the following compiler error:
[Error] .../Scala2.scala:5:22: unreachable code
[Error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=other-match-analysis, site=PetPrinter.printPet
[Error] case Cat(_) => "I'm a cat."
[Error]
Problem
The Scala 2 code should've compiled successfully.