为什么由密封类型绑定的类型参数似乎不会引发穷举警告
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 {
^