Check nullness pass knows pattern case variables can't be null

This commit is contained in:
Chris Smowton
2023-10-27 16:23:12 +01:00
parent ca43b9603a
commit e94c5a772c

View File

@@ -14,7 +14,7 @@ public class G {
switch(s) { // BAD; lack of a null case means this may throw.
case "foo" -> System.out.println("Foo");
default -> System.out.println("Something else");
case String s2 -> System.out.println("Other string of length " + s2.length());
}
}