CSR :
|
|
Relates :
|
|
Relates :
|
Summary ------- The pattern matching for switch feature should continue to be a preview feature for JDK 18, having been adjusted based on the feedback from being a preview feature in JDK 17. Problem ------- More time is needed to gain experience with the pattern matching for switch feature. Following feedback from the first preview some small amendments have been make, and feedback on these amendments and the feature in general should be gathered. Solution -------- The pattern matching for switch preview feature will continue to be a preview feature for JDK 18. The spec and compiler will be adjusted based on the current feedback. Specification ------------- The updated JLS for pattern matching for switch is attached, and is also available for convenience here: http://cr.openjdk.java.net/~gbierman/jep420/jep420-20211111/specs/patterns-switch-jls.html The current significant changes to the spec from the first preview are: * the any pattern (including an any pattern that is guarded) dominates a constant pattern of the same type * permitted types that can't be cast to the selector type of the switch statement or expression (and hence a `case` cannot be written for them) are ignored when checking exhaustiveness of a switch * the specification of the resolution of a switch block has been re-written to be more readable. This is not a semantics altering change, but rather a significant editorial change Currently no API changes. The changes to the specification and API are a subject of change until the CSR is finalized.
|