RFR: 8294943: Implement record patterns in enhanced for [v8]

Aggelos Biboudis abimpoudis at openjdk.org
Fri Nov 11 17:38:31 UTC 2022

On Fri, 11 Nov 2022 16:29:10 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Aggelos Biboudis has updated the pull request incrementally with one additional commit since the last revision:
>>   Fix parsing error in presence of nested patterns
> src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java line 2987:
>> 2985:         boolean inType = false;
>> 2986:         boolean inSelectionAndParenthesis = false;
>> 2987:         boolean sequentialIdentifiers = false;
> In general the changes look good - but please make sure that we don't get confused by lambda expressions. E.g. a lambda can be like `(type name)`, so you have two identifiers between parens. Or, even `(int x)`, so `int x` between parens - which I think will trick this code into thinking you have a record?

This qualifies as a test case to add and a new bug to fix :D 
Good catch.

static <T> void method2(Function<Integer, Integer> f) {}
int i = 42;
for (method2((Integer a) -> 42); i == 0;) { i++; }


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

More information about the compiler-dev mailing list