Skip to content

Conversation

@nate-chandler
Copy link
Contributor

Explanation: Fix inference of Sendable/BitwiseCopyable on @frozen enums in non-resilient modules like the embedded stdlib.

Previously, when type-checking the @frozen attribute on an enum, if the module was being built non-resiliently (without -enable-library-evolution), the attribute would silently be invalidated and ignored. It was ignored even if the attribute was applied to a non-exported type.

Inference of conformance to Sendable and BitwiseCopyable only proceeds on exported types if they are marked @frozen (with a non-invalidated attribute). The silent invalidation of @frozen on exported enums in non-resilient modules resulted in conformance not being inferred for those enums. For example, the embedded stdlib is built without resilience, so neither UnboundedRange_'s conformance to Sendable nor Never's conformance to BitwiseCopyable were inferred.

Here, this is fixed. Exported enums keep the attribute, and non-exported enums get a warning if the attribute is applied.

Fixes a failure to infer conformances to Sendable and BitwiseCopyable in the stdlib when building for embedded.
Scope: Affects @frozen annotations.
Issue: rdar://128358780
Original PR: #73756
Risk: Low. Does unsuppress a warning when using @frozen on non-exported enums in non-resilient modules, however.
Testing: Added a test demonstrating that Sendable/BitwiseCopyable inference on @frozen exported enums in non-resilient modules occurs as intended.
Reviewer: Doug Gregor ( @DougGregor )

Even when building not for library evolution, @Frozen is a valid
attribute on enums.

rdar://128358780
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler nate-chandler marked this pull request as ready for review May 21, 2024 20:21
@nate-chandler nate-chandler requested a review from a team as a code owner May 21, 2024 20:21
@nate-chandler nate-chandler enabled auto-merge May 21, 2024 20:32
@nate-chandler nate-chandler merged commit d7ff19f into swiftlang:release/6.0 May 21, 2024
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar128358780 branch May 21, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants