Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/IllegalFallthroughIn19Java.java
Alexandr Suhinin c68519d5f1 IDEA-297396: fix illegal fallthrough for pattern guards
GitOrigin-RevId: 41a247c8a52df15c86fcd0acc934308034a2da65
2022-07-20 19:59:35 +00:00

69 lines
1.9 KiB
Java

record RecordClass(int x) {}
public class FallThrough {
void testFallThough(Integer i, Object o) {
switch (i) {
case 1, <error descr="Illegal fall-through to a pattern">Integer x</error> -> {
}
}
switch (i) {
case 1, <error descr="Illegal fall-through to a pattern">Integer x</error> -> {
}
}
switch (i) {
case null, Integer x -> {
}
}
switch (i) {
case 1, <error descr="Illegal fall-through to a pattern">Integer x when x > 0</error> -> {
}
}
switch (o) {
case String s, <error descr="Illegal fall-through to a pattern">Integer x when x > 0</error> -> {
}
}
switch (o) {
case String s, <error descr="Illegal fall-through to a pattern">RecordClass(int x) r when x > 0</error> -> {
}
}
switch (o) {
case String s, <error descr="Illegal fall-through to a pattern">RecordClass(int x)</error> -> {
}
}
switch (o) {
case null, <error descr="Illegal fall-through to a pattern">RecordClass(int x)</error> -> {}
case default -> {}
}
switch (o) {
case RecordClass(int x) s, <error descr="Illegal fall-through from a pattern">null</error> -> {}
case default -> {}
}
switch (i) {
case 1:
case <error descr="Illegal fall-through to a pattern">Integer x</error>:
System.out.println();
break;
}
switch (i) {
case 1:
case <error descr="Illegal fall-through to a pattern">Integer x when x > 0</error>:
System.out.println();
break;
}
switch (o) {
case String s:
case <error descr="Illegal fall-through to a pattern">Integer x when x > 0</error>:
System.out.println();
break;
}
switch (o) {
case String s:
break;
case Integer x when x > 0:
System.out.println();
break;
default:
throw new IllegalStateException("Unexpected value: " + o);
}
}
}