Integrated: 8282274: Compiler implementation for Pattern Matching for switch (Third Preview)
Jan Lahoda
jlahoda at openjdk.java.net
Mon May 16 07:53:43 UTC 2022
On Mon, 11 Apr 2022 16:37:03 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
> 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!
This pull request has now been integrated.
Changeset: 0155e4b7
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/0155e4b76bb0889e516811647aede500a7812db1
Stats: 1093 lines in 56 files changed: 549 ins; 320 del; 224 mod
8282274: Compiler implementation for Pattern Matching for switch (Third Preview)
Co-authored-by: Brian Goetz <briangoetz at openjdk.org>
Co-authored-by: Jan Lahoda <jlahoda at openjdk.org>
Reviewed-by: mcimadamore, vromero, abimpoudis
-------------
PR: https://git.openjdk.java.net/jdk/pull/8182
More information about the compiler-dev
mailing list