On Wed, 4 May 2022 10:51:38 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> 8262889: Compiler implementation for Record Patterns
>> 
>> A first version of a patch that introduces record patterns into javac as a 
>> preview feature. For the specification, please see:
>> http://cr.openjdk.java.net/~gbierman/jep427+405/jep427+405-20220426/specs/patterns-switch-record-patterns-jls.html
>> 
>> There are two notable tricky parts:
>> -in the parser, it was necessary to improve the `analyzePattern` method to 
>> handle nested/record patterns, while still keeping error recovery reasonable
>> -in the `TransPatterns`, the desugaring of the record patterns is very 
>> straightforward - effectivelly the record patterns are desugared into 
>> guards/conditions. This will likely be improved in some future 
>> version/preview
>> 
>> `MatchException` has been extended to cover additional cases related to 
>> record patterns.
>
> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java line 824:
> 
>> 822:                 }
>> 823:                 for (Symbol currentType : nestedCovered) {
>> 824:                     if (types.isSubtype(types.erasure(currentType.type),
> 
> Not 100% what this test does

I think this is i) from the domination relation:

> A record pattern with type R and record component pattern list L dominates 
> another record pattern with type S and record component pattern list M if (i) 
> the erasure of S is a subtype of the erasure of R, and (ii) every pattern, if 
> any, in L dominates the corresponding pattern in M.

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

PR: https://git.openjdk.java.net/jdk/pull/8516

Reply via email to