Consider code like:
---
public class Test {
record R(int i) {}
int test(Object o) {
return switch (o) {
case R(var v) -> 0;
default -> 0;
};
}
}
---
javac compiles it without problems, but the type of "var v" in the AST is an Erroneous tree node, not a PrimitiveTypeTree, as could be expected.
---
public class Test {
record R(int i) {}
int test(Object o) {
return switch (o) {
case R(var v) -> 0;
default -> 0;
};
}
}
---
javac compiles it without problems, but the type of "var v" in the AST is an Erroneous tree node, not a PrimitiveTypeTree, as could be expected.
- relates to
-
JDK-8341901 Using 'var' keyword switch pattern matching causes compiler error
-
- Resolved
-