[pattern-switch] Opting into totality

Brian Goetz brian.goetz at oracle.com
Tue Sep 1 17:43:18 UTC 2020

Sorry, I got my examples mixed up.  I'll try to reconstruct what I was 

On 9/1/2020 1:27 PM, Dan Smith wrote:
>> On Sep 1, 2020, at 8:22 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>> But, there is a subtle difference between
>>      switch (x) {
>>          case FOO: ...
>>      }
>> and
>>      sealed switch (x) {
>>          case FOO: ....
>>          default: // nothing
>>      }
>> which is, what happens on remainder.  In the former, it is just another ignored non-matching input; in the latter, we throw.
> Confused here. Doesn't 'default' handle the remainder explicitly? Under what conditions does your sealed switch throw?
> The way I'm modeling remainder handling in my head is that sealed switches without 'default' get an implicit 'default' clause that throws. (And, for that matter, regular switches without 'default' get an implicit 'default' that is a no-op.)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20200901/a5f4e793/attachment.htm>

More information about the amber-spec-experts mailing list