Scala 类型参数规避匹配耗尽性警告

Scala 类型参数规避匹配耗尽性警告,scala,pattern-matching,compiler-warnings,type-parameter,non-exhaustive-patterns,Scala,Pattern Matching,Compiler Warnings,Type Parameter,Non Exhaustive Patterns,为什么由密封类型绑定的类型参数似乎会引发耗尽性警告 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 警告被提出了 warning: match

为什么由密封类型绑定的类型参数似乎会引发耗尽性警告

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

警告被提出了

warning: match may not be exhaustive.
It would fail on the following input: C(Some(_))
    a match {
    ^
模式匹配

def f[T <: A](a: T) =
  a match {
    case B() =>
    case C(None) =>
  }
def[T
案例C(无)=>
}
可以是详尽的,也可以不是详尽的,具体取决于
T


T听起来像个bug。
def f[T <: A](a: T) =
  a match {
    case B() =>
    case C(None) =>
  }