Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/FallthroughPatternMatchingSwitch.java
Nikita Eshkeev 196a98de7d [java][switch completion] IDEA-273874 "Can't resolve symbol" false-negative in switch with fall-through semantics
When resolving PsiSwitchLabelStatement check if it participates in the fall-through semantics and if so, stop resolving unless the previous PsiSwitchLabelStatement is of the "case null" form.

GitOrigin-RevId: 74af92cde51a8d8ec3bae1c2cd3819a09a44cdf9
2021-07-19 20:32:24 +00:00

83 lines
1.7 KiB
Java

class Main {
void f(Object o) {
switch (o) {
case null: {
}
case <error descr="Illegal fall-through to a pattern">Integer i</error>:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void g(Object o) {
switch (o) {
case null:
case Integer i:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void h(Object o) {
switch (o) {
case null: {
System.out.println();
break;
}
case Integer i:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void i(Object o) {
switch (o) {
case null:
System.out.println();
break;
case Integer i:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void k(Object o) {
switch (o) {
case String s:
System.out.println();
break;
case Integer i:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void l(Object o) {
switch (o) {
case String s: {
System.out.println();
break;
}
case Integer i:
System.out.println(i + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
void m(Object o) {
switch (o) {
case String s:
case Integer i:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error> + 1);
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
}