Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/BreakAndOtherStopWords.java
Nikita Eshkeev ee954bc169 [java switch resolve] IDEA-277110 Compilation error not highlighted when using Pattern Matching for switch
Fallthrough to default is not acceptable according to JEP 406. This patch eliminates the default cases from a special case rules and leaves only `case null` as the only special case rule.

GitOrigin-RevId: 06c865f92fed01a41c5c87e1aa0a852acb3e7ee0
2021-08-31 20:52:55 +00:00

75 lines
1.5 KiB
Java

class Main {
private void correct(Object o) {
switch (o) {
case Integer i :
System.out.println();
case null:
System.out.println(i);
case default:
};
}
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>);
}
}
}