bug
bug copied to clipboard
2.13 regression: false negative, missing unreachable warning after extractor returning `Some`
both Scala 2.12.20 and Scala 3.6.3 give an unreachable warning but Scala 2.13 does not:
trait Tree
object Tree {
def unapply(tree: Tree): Some[Int] = ???
}
object Test {
def foo(tree: Tree) =
tree match {
case Tree(_) => ???
case _ => "unreachable"
}
}
note that adding a case null => ??? line does causes the unreachable warning to emerge
the Scala 3 warning text is helpfully explicit about the status of null:
-- [E121] Pattern Match Warning: -----------------------------------------------
9 | case _ => "unreachable"
| ^
|Unreachable case except for null (if this is intentional, consider writing case null => instead).
this may be tangled up with tickets such as https://github.com/scala/bug/issues/11457