merging cases in between values and types
Brian Goetz
brian.goetz at oracle.com
Wed Sep 8 15:08:59 UTC 2021
It doesn't really matter, since 42 is subsumed into Integer anyway.
Null is the weirdo (as always.)
On 9/8/2021 2:42 AM, Remi Forax wrote:
> Hi all,
> the current spec support merging/fallthrough cases only when there is a case null,
> like
> case null, case Integer i -> // i can use 'i' here
>
> First, i'm not sure it's clearly written in the spec, i was not able to pinpoint the rule allowing it.
> Then i wonder if this special behavior is special because null is special or if it should work with any values of the type of the type pattern,
> i.e. it works because null is a possible value of Integer, in that case, it should also work with any other values like 42
>
> case 42, case Integer i -> // i can use 'i' here
>
> So is null a special value or does this rule also work with any values.
>
> regards,
> Rémi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20210908/0979fd96/attachment.htm>
More information about the amber-spec-experts
mailing list