Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/SwitchStatementUnreachableBranches.java
Tagir Valeevandintellij-monorepo-bot d09640c53d [java-dfa] Report unreachable switch branches after 100% reachable branch
Fixes IDEA-294215 Inspection "Constant conditions & exceptions" does not report all unreachable switch labels

GitOrigin-RevId: 6f1e493b6a665221c1978a5c918028638ec23c09
2022-05-18 10:20:33 +00:00

18 lines
529 B
Java

class Test {
enum Colors {
RED,
GREEN,
BLUE,
YELLOW,
}
public Test(Colors color) {
if (color == Colors.RED || color == Colors.GREEN) {
switch (color) {
case RED -> System.out.println("Red");
case <warning descr="Switch label 'BLUE' is unreachable">BLUE</warning> -> System.out.println("Blue");
case GREEN -> System.out.println("Green");
case <warning descr="Switch label 'YELLOW' is unreachable">YELLOW</warning> -> System.out.println("Yellow");
}
}
}
}