Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/BreakAndOtherStopWords.java
T
Nikita Eshkeev 127bc75ad2 [java][switch] IDEA-273959 Good code red: 'cannot resolve symbol' in preceding case label
Add the fix to properly handle situations when a case label is a special one ("case null", "case default", "default") but it's not a fallthrough one.

Move the methods that check if a statement can always execute its instructions from ControlFlowUtils to JavaControlFlowUtils in order to call them from PsiSwitchLabelStatementImpl

GitOrigin-RevId: 24c4aa3964be115b02fb499875fb97c89ea2ac08
2021-07-29 13:10:42 +00:00

75 lines
1.5 KiB
Java

class Main {
private void correct(Object o) {
switch (o) {
case Integer i :
System.out.println();
case default:
case null:
System.out.println(i);
};
}
private void f(Object o) {
switch (o) {
case Integer i :
System.out.println();
break;
case null:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error>);
}
}
private void g(Object o) {
switch (o) {
case Integer i :
System.out.println();
case null:
throw new RuntimeException();
default: {}
case default:
case null:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error>);
}
}
private void h(Object o) {
switch (o) {
case Integer i :
System.out.println();
case null:
default: {
throw new RuntimeException();
}
case default:
case null:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error>);
}
}
private void k(Object o) {
for (;;) {
switch (o) {
case Integer i:
System.out.println();
case null:
case default:
continue;
case null:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error>);
}
}
}
private void ret(Object o) {
switch (o) {
case Integer i: {
System.out.println();
return;
}
case null:
System.out.println(<error descr="Cannot resolve symbol 'i'">i</error>);
}
}
}