Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/ParameterNullabilityFromSwitch.java
Ilyas Selimov 4ff4d818aa IDEA-270442 - supported nullability for primitive boxed types, added a quick fix to insert 'null' branch
GitOrigin-RevId: ab0d83bbe5336af0ad73b2399e3b8a8cfb086bd7
2021-10-13 04:24:59 +00:00

23 lines
683 B
Java

import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.NotNull;
class Test {
static void nullable(String s) {
switch (s) {
case "xyz" -> System.out.println("xyz");
case null, default -> System.out.println("else");
}
}
static void notNullable(String s) {
switch (s) {
case "xyz" -> System.out.println("xyz");
case default -> System.out.println("else");
}
}
public static void main(String[] args) {
nullable(<warning descr="Passing 'null' argument to non-annotated parameter">null</warning>);
notNullable(<warning descr="Passing 'null' argument to parameter annotated as @NotNull">null</warning>);
}
}