[code-reflection] RFR: Erase receiver type before calling Gen::binaryQualifier
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Apr 12 12:08:51 UTC 2024
On Fri, 12 Apr 2024 12:01:35 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> I found an issue where `Gen::binaryQualifier` was called on a non-denotable reveiver type. This led to a crash, as `binaryQualifier` ended up creating a new symbol whose owner was the non-denotable receiver and, at least for some symbols, we check in the constructor that the owner can't be a type-variable.
>
> The solution is to make sure that the receiver type (`site`) passed to `binaryQualifier` is always erased, which is also the assumption `Gen` makes (obviously).
test/langtools/tools/javac/reflect/DenotableTypesTest.java line 188:
> 186: };
> 187: """)
> 188: static void test9(List<? extends Box<Integer>> list) {
Strictly speaking this test isn't needed, as it passed even w/o the fix (as cloning a VariableSymbol doesn't incur in any well-formedness check. This means a new var symbol is created with a captured variable owner, but the owner is then "normalized" to its erasure by `ReflectMethods::typeToTypeElement`, so the crash is avoided. Anyway, I preferred to add the correct call to `erasure` even for fields, and add a test, to make sure we don't regress.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/50#discussion_r1562458135
More information about the babylon-dev
mailing list