Files
openide/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlightingPatternsInSwitch/GuardWithInstanceOfPatternMatching.java
Nikita Eshkeev 827f379576 [java][guarded pattern] IDEA-273957 - Good code red: 'cannot resolve symbol' introduced in instanceof pattern
IDEA didn't use to consider that there might be instanceof patterns in the guard expression, so it ignored this part during resolution. Now IDEA tries to resolve a reference against both the pattern variable and guarding expression.

GitOrigin-RevId: 249ce6ec8ec6db84f9a5fc4622b4433550b38bf4
2021-07-28 12:11:57 +00:00

16 lines
286 B
Java

class Main {
void f(Object o) {
if (o instanceof (CharSequence cs && cs instanceof String s)) {
System.out.println(s);
}
}
void g(Object o) {
switch (o) {
case Integer i && o instanceof String s:
System.out.println(s);
default:
};
}
}