[java-intentions] ConvertSwitchToIf: don't add explicit null check if the selector expression is not null

IDEA-300120

GitOrigin-RevId: d49fa3356b23ec87c8f493fc4cdacb0655e4b600
This commit is contained in:
Andrey.Cherkasov
2022-08-18 12:48:14 +04:00
committed by intellij-monorepo-bot
parent 61b6e65651
commit 8cfde5e798
3 changed files with 35 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
// "Replace 'switch' with 'if'" "true-preview"
import org.jetbrains.annotations.NotNull;
class Test {
void foo(@NotNull Object o) {
if (o instanceof String) {
System.out.println("one");
} else if (o instanceof Integer) {
System.out.println("two");
} else {
System.out.println("default");
}
}
}

View File

@@ -0,0 +1,14 @@
// "Replace 'switch' with 'if'" "true-preview"
import org.jetbrains.annotations.NotNull;
class Test {
void foo(@NotNull Object o) {
switch<caret> (o) {
case String s -> System.out.println("one");
case Integer i -> System.out.println("two");
case default -> System.out.println("default");
}
}
}