Dart: do not generate default
clause for enumerations
#1641
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
----- Motivation -----
In the case of enumerations we match all the possible
matchable values in
case
clauses. Then, we generatedefault
clause, but the linter is able to see, thatthis is a dead code.
In such case
unreachable_switch_default
warning israised by the linter.
----- Important -----
The above is true if we generate an authentic
enum
in Dart.In the case when aliasing enumerators are needed, then
we generate an enum-like class. In such case
default
clauseis needed, because we operate on integers and compiler assumes,
that switch-case is not exhaustive.
----- Implemented solution -----
Removed generation of redundant
default
clause when we usean authentic Dart
enum
to avoid linter warnings.