RFR: 8290379: Parse error with parenthesized pattern and guard using an array

Jan Lahoda jlahoda at openjdk.org
Mon Jul 18 15:07:07 UTC 2022


On Fri, 15 Jul 2022 16:15:52 GMT, Aggelos Biboudis <abimpoudis at openjdk.org> wrote:

> Addresses the parsing error for the following case:
> 
> case (String s) when (arr[0] == 1) -> 0;

Seems reasonable, but the code may possibly be simpler.

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

> 3171:                     } else {
> 3172:                         // This is a potential guard, if we are already in a pattern
> 3173:                         return pendingResult == PatternResult.PATTERN

Why not simply `return pendingResult;`?

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

Marked as reviewed by jlahoda (Reviewer).

PR: https://git.openjdk.org/jdk/pull/9519


More information about the compiler-dev mailing list