Expression switch exception naming
cushon at google.com
Fri Mar 30 18:58:27 UTC 2018
On Fri, Mar 30, 2018 at 11:40 AM Brian Goetz <brian.goetz at oracle.com> wrote:
> - We'd additionally consider an expression switch to be exhaustive if
> all known enums are present _and_ the enum type is in the same module as
> the switch
> But that's probably too fussy.
I think it would be surprising for this to depend on where the declaration
enum was located.
Treating expression switches that handle all constants of an enum as
exhaustive might be most valuable across compatibility boundaries. If the
enum is declared nearby, adding a method to the enum is often a good
alternative to switching on it. When switches are used to associate
behaviour with enums in other libraries that can't be modified directly,
a way to ensure those switches are updated if values are added to the enum
eliminates a category of bugs.
More information about the amber-spec-observers