code |
sealed trait Elem
case class Foo extends Elem
case class Bar extends Elem
trait Row extends Elem
object Row {
def unapply(r: Row) = true
}
def f(elem: Elem) {
elem match {
case Bar() =>
case Row() =>
case Foo() => // ERROR: unreachable code
}
}
If Row is changed to a case class or the unapply parameter type to Elem, it compiles.
The error depends on whether and where the Row case is inserted. The above seems to be the only permutation that does not compile. The following, e.g., compiles:
def f(elem: Elem) {
elem match {
case Row() =>
case Bar() =>
case Foo() =>
}
} |