Closed
Description
A simplification of #6088
minimized code
object GADT {
import =:=._
enum =:=[A, B] {
case Refl[C]() extends (C =:= C)
}
def unwrap[A,B](opt: Option[A])(using ev: A =:= Option[B]): Option[B] = ev match {
case Refl() => opt.flatMap(identity[Option[B]])
}
}
error:
-- [E029] Pattern Match Exhaustivity Warning: GADT.scala:7:74
7 | def unwrap[A,B](opt: Option[A])(given ev: A =:= Option[B]): Option[B] = ev match {
| ^^
| match may not be exhaustive.
|
| It would fail on pattern case: =:=.Refl()
The warning goes away if you make A
contravariant.
expectation
No warning