RFR: 8309469: Pattern dominance should be adjusted

Vicente Romero vromero at openjdk.org
Wed Jun 7 17:34:03 UTC 2023


On Mon, 5 Jun 2023 14:48:13 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> Currently, when a switch contains both patterns and constant labels, any pattern case dominates the constant label. E.g. the following example currently produces a compile-time error:
> 
> switch (...) {
>     case Integer i when i == 0 -> {}
>     case 1 -> {} //dominated by the preceding case
>     case Integer i -> {}
> }
> 
> 
> But, the rules are now (to be) relaxed in the spec, so that guarded cases (with patterns) don't dominate cases with constant labels. I.e. the above example is supposed to compile and run fine.
> 
> This PR is implementing this change - when checking patter-constant dominance, we only consider unguarded cases.

looks good to me

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/14314#pullrequestreview-1468222991


More information about the compiler-dev mailing list