Почему параметр типа, связанный с запечатанным типом, кажется, не вызывает предупреждение об исчерпании возможностей
sealed trait A
case class B() extends A
case class C(i: Option[Int]) extends A
def f[T <: A](a: T) =
a match {
case B() =>
case C(None) =>
}
f(C(Some(42))) // throws MatchError
пока без параметра типа
def f(a: A) =
a match {
case B() =>
case C(None) =>
}
предупреждение поднято
warning: match may not be exhaustive.
It would fail on the following input: C(Some(_))
a match {
^