Skip to content

[6.2][AST/Sema] SE-0487: Implement @nonexhaustive attribute and new enum exhaustivity checking rule #82922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 21, 2025

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Jul 9, 2025

@xedin xedin requested a review from a team as a code owner July 9, 2025 18:09
@xedin xedin added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Jul 9, 2025
@xedin
Copy link
Contributor Author

xedin commented Jul 9, 2025

@swift-ci please test

@xedin xedin force-pushed the nonexhaustive-enums-6.2 branch from 218aeeb to afa6d64 Compare July 9, 2025 18:17
@xedin
Copy link
Contributor Author

xedin commented Jul 9, 2025

@swift-ci please test

@xedin xedin marked this pull request as draft July 10, 2025 00:44
@xedin
Copy link
Contributor Author

xedin commented Jul 10, 2025

@swift-ci please test Windows platform

xedin added 8 commits August 18, 2025 23:56
This attribute controls whether cross-module access to the declaration
needs `@unknown default:` because it's allowed to gain new cases even
if the module is non-resilient.

(cherry picked from commit a0ae93d)
For now the semantics provided by `@extensible` keyword on per-enum
basis. We might return this as an upcoming feature in the future with
a way to opt-out.

(cherry picked from commit bf19481)
…tribute

Guard against condfails when older compilers get a swift interface
that uses `@extensible` attribute. The attribute itself doesn't
have any effect in swift interfaces yet since all of the public
enums are already resilient in that mode.

(cherry picked from commit 6d89bca)
…s for extensible enums

Just like `@preconcurrency` for concurrency, this attribute is going
to allow exhaustiveness error downgrades for enums that were retroactively
marked as `@extensible`.

(cherry picked from commit 498430a)
This is an accepted spelling for the attribute. This commit
also renames the feature flag from `ExtensibleAttribute` to
`NonexhaustiveAttribute` to match the spelling of the attribute.

(cherry picked from commit fe1ae75)
…n` argument

The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.

(cherry picked from commit 43eec8f)
@xedin xedin force-pushed the nonexhaustive-enums-6.2 branch from afa6d64 to 1d65a56 Compare August 19, 2025 06:58
@xedin
Copy link
Contributor Author

xedin commented Aug 19, 2025

@swift-ci please test

The proposal [has been accepted](https://forums.swift.org/t/accepted-se-0487-nonexhaustive-enums/81508)
which makes the feature experimental no longer.

(cherry picked from commit a7ecd30)
@xedin xedin marked this pull request as ready for review August 20, 2025 16:25
@xedin
Copy link
Contributor Author

xedin commented Aug 20, 2025

@swift-ci please test

@xedin xedin merged commit f408b2d into swiftlang:release/6.2 Aug 21, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants