mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
[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:
committed by
intellij-monorepo-bot
parent
61b6e65651
commit
8cfde5e798
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user