mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-05 04:40:28 +07:00
[java-highlighting] IDEA-202570 Unreachable statement inspection should highlight whole switch expression
Also, fixed unreachable statement highlighting in different cases GitOrigin-RevId: 20b28272b51c77e3413e1ca143222d35199728bd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ae33969db0
commit
325edf9af2
@@ -0,0 +1,62 @@
|
||||
public class DeadCode {
|
||||
private static String m1(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">return</error> switch (1) {
|
||||
default -> "x";
|
||||
};
|
||||
}
|
||||
|
||||
private static String m2(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">int x = switch (1) {
|
||||
default -> 0;
|
||||
};</error>
|
||||
}
|
||||
|
||||
private static String m3(int n) {
|
||||
int x;
|
||||
return "";
|
||||
<error descr="Unreachable statement">x = switch (1) {
|
||||
default -> 0;
|
||||
};</error>
|
||||
}
|
||||
|
||||
private static String m4(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">throw</error> switch (1) {
|
||||
default -> new RuntimeException();
|
||||
};
|
||||
}
|
||||
|
||||
private static String m5(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">try</error> (AutoCloseable x = switch(1) {default -> () -> {};}) {} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String m6(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">synchronized</error> (switch(1) {default -> "";}) {
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
private static String m7(int n) {
|
||||
return "";
|
||||
<error descr="Unreachable statement">if</error>(switch (1) {default -> true;}) {}
|
||||
}
|
||||
|
||||
private static String m8(int n) {
|
||||
return switch (n) {
|
||||
default:
|
||||
yield "x";
|
||||
<error descr="Unreachable statement">yield</error> switch(1) { default -> ""; };
|
||||
};
|
||||
}
|
||||
|
||||
private static String m9() {
|
||||
return "";
|
||||
<error descr="Unreachable statement">assert</error> switch(1) {default -> true;};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user