[6.2][AST/Sema] SE-0487: Implement @nonexhaustive
attribute and new enum exhaustivity checking rule
#82922
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.
Explanation:
This is an implementation of a second revision of SE-0487 proposal to
make non-frozen enums extensible for non-resilient cross-module access.
The new attribute (
@nonexhaustive
) controls whether cross-module accessto the declaration needs
@unknown default:
because it's allowed to gain newcases even if the module is non-resilient. A variant of the flag
@nonexhaustive(warn)
could be used by API authors to push error about non-exhaustive use farther into the
future.
Resolves: rdar://154965992
Main Branch PRs: [AST/Sema] Add
@extensible
attribute onenum
declarations #80503, [Frontend] AddExtensibleAttribute
to guard use of@extensible
at… #81073, [AST/Sema] Add@preEnumExtensibility
attribute to downgrade warning… #81176, [AST/Sema] SE-0487: Adjust implementation based on the LSG feedback #82807Risk: Very Low. These changes are guarded by an experimental feature
NonexhaustiveAttribute
which is not enabled by default yet.Reviewed By: @FranzBusch
Testing: Added new test-cases.