Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/PatternMatchingScope.java
Nikita Eshkeev e807464037 [java][switch] IDEA-273874 "Can't resolve symbol" false-negative in switch with fall-through semantics
Resolve as many references as possible in order to keep the GoToSymbol action available but move invalid references in pattern matching for switch to the highlighter pass as the code review suggests

GitOrigin-RevId: 2339b7c9cd02b0d1e3c793c30a8a3338c28c9b73
2021-07-26 08:04:43 +00:00

35 lines
865 B
Java

public class Main {
int expr(Object o) {
return switch(o) {
case String s -> 1;
case String s1 -> <error descr="Cannot resolve symbol 's'">s</error>.length();
case Integer i -> i;
default -> 0;
};
}
static void statement(Object o) {
switch(o) {
case String s:
case String s1:
System.out.println(<error descr="Cannot resolve symbol 's'">s</error>.length());
case Integer i:
System.out.println(i);
default:
System.out.println(1);
};
}
static void nested(Object o, String title) {
String header = "Hello";
switch (o) {
case String s:
switch (o) {
case String <error descr="Variable 's' is already defined in the scope">s</error>:
case String s1:
System.out.println(title + header + ":" + s);
}
}
}
}