Closed
Description
Given the following code:
sealed trait Foo[A]
case class One[A]() extends Foo[A]
sealed abstract case class Bar[A]() extends Foo[A]
class Two() extends Bar[String]
object Test {
def test(x: Foo[Int]) = x match {
case One() =>
}
}
The exhaustiveness checker is smart enough to not warn, because no instance of Bar
is a subtype of Foo[Int]
.
However, if we add a case for Bar()
like this:
sealed trait Foo[A]
case class One[A]() extends Foo[A]
sealed abstract case class Bar[A]() extends Foo[A]
class Two() extends Bar[String]
object Test {
def test(x: Foo[Int]) = x match {
case One() =>
case Bar() =>
}
}
We should get an unreachable code warning (and indeed, scalac produces one), but we don't.