> On Aug 22, 2020, at 2:06 PM, Brian Goetz <brian.go...@oracle.com> wrote:
> . . .
>> 
>> Option 1: If the type of the switch expression is an enum or a sealed type, 
>> then it is a static error if the patterns are not at least optimistically 
>> total.  **This would be an incompatible change with respect to existing 
>> switches on enum types.**
> 
> Actually, as stated, this is not inconsistent -- for switch *expressions*.  
> We added switch expressions in Java 12 and required that they be total, and, 
> when the target is an enum, we nodded to optimistic totality, by not 
> requiring a `default` when the cases were optimistically total.  Where we 
> don't have an equivalent story is for switch *statements*, which have always 
> been partial -- and for which partiality is reasonable (just as an `if` 
> without an `else` is reasonable.)  And the story for optimistic totality does 
> not scale quite as well as we'd hoped to sealed types, for a few reasons:

Yes, this was an error on my part; I meant to write "Option 1: If the type of 
the switch statement is . . .”

Reply via email to