Open
Description
This produces no warning, but is not exhaustive:
sealed trait Foo
final case class Bar[A](a: A) extends Foo
def test(x: Foo) = x match {
case Bar(a: Int) =>
}
This produces both an inexhaustivity and unchecked warnng, but it is exhaustive because of erasure:
sealed trait Foo
final case class Bar[S](s: S => Unit) extends Foo
def test(x: Foo) = x match {
case Bar(s: (Any => Unit)) =>
}
-- [E029] Pattern Match Exhaustivity Warning: try/ce.scala:19:19 ---------------
19 |def test(x: Foo) = x match {
| ^
| match may not be exhaustive.
|
| It would fail on pattern case: Bar(_)
longer explanation available when compiling with `-explain`
-- Warning: try/ce.scala:20:11 -------------------------------------------------
20 | case Bar(s: (Any => Unit)) =>
| ^^^^^^^^^^^^^^^^
| the type test for Any => Unit cannot be checked at runtime
(Adding a case Bar(_) =>
should in fact produce an unreachability warning).