Files
openide/java/java-tests/testData/inspection/dataFlow/fixture/WhenPatterns.java
T
Tagir Valeevandintellij-monorepo-bot 9e458c909c [java-highlighting] checkLabelSelectorCompatibility extracted and moved to SwitchChecker
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: bec076c5bff67e22d06e64e573d3219a4c89dd4d
2025-02-19 17:57:38 +00:00

29 lines
948 B
Java

class Test {
int testIncomplete(Object obj) {
return <error descr="Switch expression should produce a result in all execution paths">switch</error>(obj) {
case String s when<EOLError descr="Expression expected"></EOLError><EOLError descr="':' or '->' expected"></EOLError>
};
}
int test3(String s1) {
return switch(s1) {
case String s when s.length() <= 3 && (s.length() > 1 || <warning descr="Condition 's.length() > 10' is always 'false' when reached">s.length() > 10</warning>) -> 1;
default -> 3;
};
}
int test4(String s) {
return switch (s) {
case String ss when (ss.length() < 3 || ss.length() == 4) -> 1;
default -> 3;
};
}
int test5(Object o) {
return switch(o) {
case String s when s.length() > 5 -> 1;
case String s1 when <warning descr="Condition 's1.length() > 10' is always 'false'">s1.length() > 10</warning> -> 2;
default -> 3;
};
}
}