RFR: 8375646: Some parser flags seem unused [v2]

Jan Lahoda jlahoda at openjdk.org
Mon Jan 19 18:14:51 UTC 2026


On Mon, 19 Jan 2026 16:41:11 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Some of the flags in `JavacParser` are never set, such as `TYPEARGS` and `NOPARAMS`.
>> 
>> Another flag, namely `NODIAMOND` can easily be avoided by looking ahead one token.
>> 
>> This PR removes all the three flags. The main issue with these changes had to do with removing the `boolean allowDiamon` parameter from the `typeArguments` method, as doing so makes it clash with another similarly named method.
>> For this reason, this PR distinguish between:
>> 
>> * `typeArguments` -- a method that parses a type argument list, returns a list of `JCExpression`s
>> * `typeApply` -- a method that parses and applies type arguments to an existing type (a `JCExpression). This returns a new `JCExpression` (typically a `JCTypeApply`).
>
> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Drop redundant local var

Overall, looks good to me, but unless I am missing something, the logic on one place is changed in this PR? There's a comment inline.

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 1443:

> 1441:         switch (token.kind) {
> 1442:         case QUES:
> 1443:             if (isMode(TYPE) && isMode(TYPEARG) && !isMode(NOPARAMS)) {

Not sure if I read the code right, but `TYPEARG` is never set, so `isMode(TYPEARG)` is always `false`, and the whole "then" section of the if should be removed and only the "else" section preserved? Or, quite possibly, the this whole `case QUES` can be removed (and `?` handled by `default`)?

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

PR Review: https://git.openjdk.org/jdk/pull/29302#pullrequestreview-3679167045
PR Review Comment: https://git.openjdk.org/jdk/pull/29302#discussion_r2705700028


More information about the compiler-dev mailing list