Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/SuspiciousLabelElements.java
Mikhail Pyltsin 43ad0b4707 [java-inspection] IDEA-281947 Useless pattern guard not suggested for removal
- remove guard if it is always true

GitOrigin-RevId: 168a103e93a42c9a82657abffcbd7626047cab3d
2023-12-14 19:49:09 +00:00

37 lines
1.1 KiB
Java

public class DuplicateLabels {
void testDuplicateLabels(String s) {
switch (s) {
case <error descr="Duplicate label 'foo'">"foo"</error>, <error descr="Duplicate label 'null'">null</error>:
System.out.println("A");
break;
case <error descr="Duplicate label 'foo'">"foo"</error>:
System.out.println("B");
break;
case <error descr="Duplicate label 'null'">null</error>:
System.out.println("C");
}
}
void testDuplicatePatterns(String s) {
switch (s) {
case "abc":
break;
case <error descr="Duplicate unconditional pattern">Object oo</error>:
break;
case <error descr="Duplicate unconditional pattern">Object oo</error> when <warning descr="Condition is always true">true</warning>:
break;
}
}
void testDominatedPatterns(Object o) {
switch (o) {
case String ss when <warning descr="Condition is always true">true</warning>:
break;
case <error descr="Label is dominated by a preceding case label 'String ss'">String ss</error>:
break;
default:
break;
}
}
}