RFR: 8282274: Compiler implementation for Pattern Matching for switch (Third Preview) [v10]
Jan Lahoda
jlahoda at openjdk.java.net
Mon May 9 14:18:22 UTC 2022
> This is a (preliminary) patch for javac implementation for the third preview of pattern matching for switch (type patterns in switches).
>
> Draft JLS:
> http://cr.openjdk.java.net/~gbierman/PatternSwitchPlusRecordPatterns/PatternSwitchPlusRecordPatterns-20220407/specs/patterns-switch-jls.html
>
> The changes are:
> -there are no guarded patterns anymore, guards are not bound to the CaseElement (JLS 15.28)
> -a new contextual keyword `when` is used to add a guard, instead of `&&`
> -`null` selector value is handled on switch level (if a switch has `case null`, it is used, otherwise a NPE is thrown), rather than on pattern matching level.
> -total patterns are allowed in `instanceof`
> -`java.lang.MatchException` is added for the case where a switch is exhaustive (due to sealed types) at compile-time, but not at runtime.
>
> Feedback is welcome!
>
> Thanks!
Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits:
- Merge branch 'master' into type-patterns-third
- Merge branch 'master' into type-patterns-third
- Reducing MatchException constructors.
- Merge branch 'master' into type-patterns-third
- Reference-type pattern is not applicable at a selector of a primitive type - fixing.
- Merge branch 'master' into type-patterns-third
- Cleanup, fixing tests.
- Cleanup - more total -> unconditional pattern renaming.
- Adjusting to review feedback.
- Cleanup.
- ... and 12 more: https://git.openjdk.java.net/jdk/compare/4f5d73f2...1101ad46
-------------
Changes: https://git.openjdk.java.net/jdk/pull/8182/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8182&range=09
Stats: 860 lines in 52 files changed: 424 ins; 244 del; 192 mod
Patch: https://git.openjdk.java.net/jdk/pull/8182.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/8182/head:pull/8182
PR: https://git.openjdk.java.net/jdk/pull/8182
More information about the compiler-dev
mailing list