RFR: 8302344: Compiler Implementation for Unnamed patterns and variables (Preview) [v12]

Vicente Romero vromero at openjdk.org
Thu May 4 17:51:22 UTC 2023

On Thu, 4 May 2023 17:20:35 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>   8307444: java.lang.AssertionError when using unnamed patterns
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 3591:
>> 3589:                 }
>> 3590:             }
>> 3591:             result = toP(F.at(pos).VarDef(mods, name, type, init, declaredUsingVar));
> I think this should check whether name is underscore (and feature is enabled) and, if that's the case, replace the name with an empty name, so that the rest of the compiler is already correct.
> Also, related, no matter what, I think javac's Pretty class should be updated to render variables with empty name as "_" when the tree is turned back into source.

yep I agree with this, the parser should set the right name as soon as it sees a `_`


PR Review Comment: https://git.openjdk.org/jdk/pull/13528#discussion_r1185327903

More information about the compiler-dev mailing list