Skip to content

Conversation

@nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented May 20, 2024

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

Fixes an issue where conformances to Sendable and BitwiseCopyable of @frozen enums are not inferred in targets not built for library evolution such as the embedded stdlib.

rdar://128358780

@nate-chandler
Copy link
Contributor Author

Alternatively

diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp
index efe408787f6..75d2bfd4e47 100644
--- a/lib/Sema/TypeCheckAttr.cpp
+++ b/lib/Sema/TypeCheckAttr.cpp
@@ -3960,11 +3960,6 @@ void AttributeChecker::visitImplementsAttr(ImplementsAttr *attr) {

 void AttributeChecker::visitFrozenAttr(FrozenAttr *attr) {
   if (auto *ED = dyn_cast<EnumDecl>(D)) {
-    if (!ED->getModuleContext()->isResilient()) {
-      attr->setInvalid();
-      return;
-    }
-
     if (ED->getFormalAccess() < AccessLevel::Package &&
         !ED->getAttrs().hasAttribute<UsableFromInlineAttr>()) {
       diagnoseAndRemoveAttr(attr, diag::enum_frozen_nonpublic, attr);

@DougGregor
Copy link
Member

Alternatively

This is the way! The attribute checker shouldn't be marking this attribute invalid.

@nate-chandler nate-chandler changed the title Infer Sendable/BitwiseCopyable for frozen types in non-evolving libraries. [TypeCheckAttr] @frozen is valid even when building without enable-library-evolution May 20, 2024
@nate-chandler nate-chandler requested a review from DougGregor May 20, 2024 22:47
@nate-chandler nate-chandler marked this pull request as ready for review May 20, 2024 22:47
@slavapestov
Copy link
Contributor

Nice find!

Looking through the git history here, we used to diagnose an error until bf4aaac. Makes sense this shouldn't depend on language mode.

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
Copy link
Contributor Author

@swift-ci Please Test Source Compatibility Debug

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.

3 participants