Files
Tagir Valeev f91bf8e788 [java-psi] Fix resolve for patterns in guards of old-style switch labels (relates to IDEA-326939)
GitOrigin-RevId: 77b81cc6df6c9b600b31261a3e83c1f552f5d06f
2023-09-06 18:14:02 +00:00

35 lines
791 B
Java

import java.util.function.*;
interface Something {
}
enum E implements Something {A, B,}
record P(String s) implements Something {
}
class Test {
public static void main(String[] args) {
}
public int main1(Something something) {
return switch (something) {
case P(_) when something instanceof Object o: yield o.hashCode();
case E _ when something instanceof Object o: yield o.hashCode();
default: {
yield 2;
}
};
}
public int main2(Something something) {
return switch (something) {
case P(_) when something instanceof Object o: yield o.hashCode();
case E _ when something instanceof Object o1: yield <error descr="Cannot resolve symbol 'o'">o</error>.hashCode();
default: {
yield 2;
}
};
}
}