On Sat, 7 May 2022 12:03:04 GMT, Jan Lahoda <jlah...@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.
>
> Jan Lahoda has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - Fixing guards after record patterns.
>  - Raw types are not allowed in record patterns.

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 4208:

> 4206:         if (site.tsym.kind == Kind.TYP && ((ClassSymbol) 
> site.tsym).isRecord()) {
> 4207:             ClassSymbol record = (ClassSymbol) site.tsym;
> 4208:             if (record.type.getTypeArguments().nonEmpty()) {

There is a `Type::isRaw()` - I supposed you tried that one? Doesn't it do what 
you want?

test/langtools/tools/javac/patterns/DeconstructionPatternErrors.out line 3:

> 1: DeconstructionPatternErrors.java:15:28: 
> compiler.err.underscore.as.identifier
> 2: DeconstructionPatternErrors.java:15:29: compiler.err.expected: 
> token.identifier
> 3: DeconstructionPatternErrors.java:43:37: compiler.err.illegal.start.of.type

should error be more specific here? E.g. diamond not supported with type test 
pattern?

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

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

Reply via email to