RFR: 8375571: Compiler crash when using record pattern matching with a generic type parameter shadowing a record class

Vicente Romero vromero at openjdk.org
Wed Jan 28 18:41:51 UTC 2026


On Mon, 26 Jan 2026 09:06:19 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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.

looks good to me

-------------

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/29407#pullrequestreview-3718384063


More information about the compiler-dev mailing list