Files
Mikhail Pyltsin afe84f8eed [java-highlighting] IDEA-324474 Highlight unreachable statement for exhaustive switch. Tests
GitOrigin-RevId: 97f525a579bd45c6863a6662142f26193e7e2429
2023-07-14 16:14:48 +00:00

48 lines
796 B
Java

public class Switches {
enum E {
A, B
}
int testReachability(E e) {
switch (e) {
case E d when d == E.A:
return 1;
case A:
return -1;
case B:
return -2;
}
<error descr="Unreachable statement">return</error> 1;
}
sealed interface T {
}
final class T1 implements T {
}
final class T2 implements T {
}
void testReachability2(T i) {
switch (i) {
case T1 f:
throw new RuntimeException();
case T2 s:
throw new RuntimeException();
}
<error descr="Unreachable statement">System.out.println();</error>
}
class Reachability2{
sealed interface T{}
final class T1 implements T{}
int test(T t) {
switch (t) {
case T1 t1: return 2;
}
}
}
}