CSR :
|
|
Relates :
|
|
Relates :
|
Summary ------- Based on experiences with the several rounds of preview of record patterns, we propose a reduction in the feature. We also propose to make the feature final and permanent. Problem ------- We've identified that the record patterns in enhanced for loops, introduced in the previous round of preview, may need a significant redesign, to better align with other features under consideration. The rest of the record patterns feature is, however, well vetted. We therefore propose to drop the record patterns in enhanced for loops sub-feature, and finalize the record patterns feature without this sub-feature. The rules for exhaustiveness of switch statements and expressions in presence of record patterns were found to not be sufficient. A new set of rules for exhaustiveness is being proposed as a solution to this problem. Solution -------- The record patterns in enhanced for loops sub-feature will be dropped from: - the specification - the javac implementation - the Trees API. The relevant `EnhancedForLoopTree.getVariableOrRecordPattern`, `EnhancedForLoopTree.getDeclarationKind` and `InstanceOfTree.getTestKind` methods and `EnhancedForLoopTree.DeclarationKind` and `InstanceOfTree.TestKind` enums are marked as preview API, and therefore can be removed. The exhaustivity rules for switches in presence of record patterns will be enhanced. Please see CSR JDK-8304394 for more details. The rest of the record patterns feature will be made final and permanent. Specification ------------- The specification draft is available for convenience [here](https://cr.openjdk.org/~gbierman/jep440%2B441/jep440%2B441-20230509/specs/patterns-switch-record-patterns-jls.html) and is attached as" 20230509 Pattern Matching for switch and Record Patterns.pdf". Please note that, for technical reasons, the specification draft also includes changes for JEP-441 (https://openjdk.org/jeps/441), which are reviewed under CSR JDK-8304394. The specdiff of API changes is available [here](https://cr.openjdk.org/~jlahoda/8300543/specdiff.00/overview-summary.html) and is attached as specdiff.00.zip. Please note that, for technical reasons, the specdiff also includes changes for JEP-441 (https://openjdk.org/jeps/441), which are reviewed under CSR JDK-8304394. The feature will be made final and permanent.
|