[External] : Re: Treatment of total patterns (was: Reviewing feedback on patterns in switch)

Brian Goetz brian.goetz at oracle.com
Wed Jan 26 12:40:05 UTC 2022


> I strongly support this change.
> 
> In my experience, it's much more important to have automatic
> refactorings between switch and chains of 'if' than between nested and
> flat switches.

Of course, this might be partially because we *have* chains of if else now, but no switches on nested patterns.  Still, I agree that the if-else refactor case is important.  To that point, a total pattern in a switch gets translated as `else` rather than `else if`, and it would be nice if the IDE recognized `case null, Object o` as being total in this case, and a null-hostile switch needs the implicit null check translated when going from switch -> if else chain.  

It would be great to write down the refactoring asymmetries in one place, just to see a “total" picture of how distortive any given treatment is?



More information about the amber-spec-observers mailing list