mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-06 09:36:56 +07:00
Fix the resolve algorithm according to [JEP 406](https://openjdk.java.net/jeps/406). It includes: - The correct resolution of variables in pattern matching guards in both if and switch - Restricting the maximal scope of resolving by the PsiSwitchLabeledRuleStatement - Various tests for resolving variable in pattern matching for switch Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com> GitOrigin-RevId: 1efb10f50a458a382a71ffeaef5a0f540b4a8893
35 lines
865 B
Java
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);
|
|
}
|
|
}
|
|
}
|
|
} |