在 Scala 2.10.0-M4 中
object X
def f(e: Either[Int, X.type]) = e match {
case Left(i) => i
case Right(X) => 0
}
给出:
warning: match may not be exhaustive.
It would fail on the following input: Right(<not X>)
这个对吗?当然,比赛实际上是详尽无遗的。
(同时,回到 Scala 2.9.X 我们得到
error: pattern type is incompatible with expected type;
found : object X
required: X.type
case Right(X) => 0
这大概是一个错误。)