mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-07 19: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
22 lines
778 B
Java
22 lines
778 B
Java
|
|
class Main {
|
|
static int m(Object o) {
|
|
|
|
int i1 = switch(<error descr="Incompatible types. Found: 'java.lang.Object', required: 'char, byte, short, int, Character, Byte, Short, Integer, String, or an enum'">o</error>) {
|
|
case String s && s.length() > 0 -> s.length();
|
|
case String s -> s.length();
|
|
default -> 1;
|
|
};
|
|
|
|
int i2 = switch(<error descr="Incompatible types. Found: 'java.lang.Object', required: 'char, byte, short, int, Character, Byte, Short, Integer, String, or an enum'">o</error>) {
|
|
case String s && (s.length() > 0) -> s.length();
|
|
case String s -> s.length();
|
|
default -> 1;
|
|
};
|
|
|
|
if (o instanceof (String s && s.length() > 0)) {}
|
|
if (o instanceof (String s && (s.length() > 0))) {}
|
|
|
|
return i1 + i2;
|
|
}
|
|
} |