RFR: 8375571: Compiler crash when using record pattern matching with a generic type parameter shadowing a record class
Jan Lahoda
jlahoda at openjdk.org
Mon Jan 26 09:13:59 UTC 2026
Consider code like:
<T> void typeVarTest(T p) {
if (p instanceof T(int i) && i == 0); //T is a type variable
}
The `T` in the deconstruction pattern will be resolve to `TypeVariableSymbol`, which has kind `TYP`, but is not `ClassSymbol`, so the cast will fail. Using `instanceof ClassSymbol` would work better, which is what this PR is doing.
-------------
Commit messages:
- Updating copyright year.
- 8375571: Compiler crash when using record pattern matching with a generic type parameter shadowing a record class
Changes: https://git.openjdk.org/jdk/pull/29407/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29407&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8375571
Stats: 31 lines in 3 files changed: 7 ins; 1 del; 23 mod
Patch: https://git.openjdk.org/jdk/pull/29407.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29407/head:pull/29407
PR: https://git.openjdk.org/jdk/pull/29407
More information about the compiler-dev
mailing list