[java-inspection] IDEA-281947 Useless pattern guard not suggested for removal

- remove guard if it is always true

GitOrigin-RevId: 168a103e93a42c9a82657abffcbd7626047cab3d
This commit is contained in:
Mikhail Pyltsin
2023-12-14 13:42:42 +01:00
committed by intellij-monorepo-bot
parent d32a572c78
commit 43ad0b4707
11 changed files with 121 additions and 32 deletions

View File

@@ -0,0 +1,9 @@
// "Remove guard expression" "true-preview"
class X {
private static void test(Object o) {
switch (o) {
case String t -> System.out.println(1);
case Object o1 -> System.out.println(1);
}
}
}

View File

@@ -0,0 +1,14 @@
// "Remove guard expression" "true-preview"
class X {
private static void test2(Object o) {
switch (o) {
case String t:
System.out.println(1);
break;
case Object o1:
System.out.println(1);
break;
}
}
}

View File

@@ -0,0 +1,9 @@
// "Remove guard expression" "true-preview"
class X {
private static void test(Object o) {
switch (o) {
case String t when 1==<caret>1 -> System.out.println(1);
case Object o1 -> System.out.println(1);
}
}
}

View File

@@ -0,0 +1,14 @@
// "Remove guard expression" "true-preview"
class X {
private static void test2(Object o) {
switch (o) {
case String t when tr<caret>ue:
System.out.println(1);
break;
case Object o1:
System.out.println(1);
break;
}
}
}