Closed
Description
Dotty reports that in the following, one case is not reachable. Extractors should be better handled to avoid such annoying warnings.
sealed trait Expr
class IntExpr extends Expr
class BooleanExpr extends Expr
object IntExpr {
def unapply(expr: Expr): Option[IntExpr] = ???
}
object BooleanExpr {
def unapply(expr: Expr): Option[BooleanExpr] = ???
}
class Test {
def foo(x: List[Expr]): Int = x match {
case IntExpr(_) :: xs => 1
case BooleanExpr(_) :: xs => 1 // <== unreachable
case Nil => 2
}
}