dotty
dotty copied to clipboard
Inaccurate warning in pattern matcher
1 class Foo {
2 val s: String = ???
3 s match {
4 case x: String => 1
5 // Test that this isn't marked as unreachable (because pattern matching) type tests
6 // use isInstanceOf and null.isInstanceOf[T] returns false for all T.
7 case null => 2
8 }
9 }
-- [E122] Syntax Warning: tests/pos/explicit-null-pattern-matching2.scala:4:9 --
4 | case x: String => 1
| ^^^^^^^^^
|The highlighted type test will always succeed since the scrutinee type (class String) is t
This is inaccurate because case x: String won't match null.
Possibly (probably) an upstream bug.