Skip to content

Commit f0aa891

Browse files
committed
[AST/Sema] Decouple @preconcurrency conformances from DynamicActorIsolation feature flag
(cherry picked from commit 3a0acf8)
1 parent d0c76d6 commit f0aa891

File tree

4 files changed

+24
-56
lines changed

4 files changed

+24
-56
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5687,8 +5687,6 @@ ERROR(preconcurrency_not_inheritance_clause,none,
56875687
"'preconcurrency' attribute only applies in inheritance clauses", ())
56885688
ERROR(preconcurrency_not_existential,none,
56895689
"'preconcurrency' attribute cannot apply to non-protocol type %0", (Type))
5690-
ERROR(preconcurrency_attr_disabled,none,
5691-
"attribute requires '-enable-experimental-feature DynamicActorIsolation'", ())
56925690

56935691
ERROR(redundant_any_in_existential,none,
56945692
"redundant 'any' in type %0",

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -643,29 +643,7 @@ static bool usesFeatureTransferringArgsAndResults(Decl *decl) {
643643
return false;
644644
}
645645

646-
static bool usesFeatureDynamicActorIsolation(Decl *decl) {
647-
auto usesPreconcurrencyConformance = [&](const InheritedTypes &inherited) {
648-
return llvm::any_of(
649-
inherited.getEntries(),
650-
[](const InheritedEntry &entry) { return entry.isPreconcurrency(); });
651-
};
652-
653-
if (auto *T = dyn_cast<TypeDecl>(decl))
654-
return usesPreconcurrencyConformance(T->getInherited());
655-
656-
if (auto *E = dyn_cast<ExtensionDecl>(decl)) {
657-
// If type has `@preconcurrency` conformance(s) all of its
658-
// extensions have to be guarded by the flag too.
659-
if (auto *T = dyn_cast<TypeDecl>(E->getExtendedNominal())) {
660-
if (usesPreconcurrencyConformance(T->getInherited()))
661-
return true;
662-
}
663-
664-
return usesPreconcurrencyConformance(E->getInherited());
665-
}
666-
667-
return false;
668-
}
646+
UNINTERESTING_FEATURE(DynamicActorIsolation)
669647

670648
UNINTERESTING_FEATURE(BorrowingSwitch)
671649

lib/Sema/TypeCheckType.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,28 +3329,21 @@ TypeResolver::resolveAttributedType(TypeRepr *repr, TypeResolutionOptions option
33293329
}
33303330

33313331
if (auto preconcurrencyAttr = claim<PreconcurrencyTypeAttr>(attrs)) {
3332-
auto &ctx = getASTContext();
3333-
if (ctx.LangOpts.hasFeature(Feature::DynamicActorIsolation)) {
3334-
if (ty->hasError())
3335-
return ty;
3336-
3337-
if (!options.is(TypeResolverContext::Inherited) ||
3338-
getDeclContext()->getSelfProtocolDecl()) {
3339-
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3340-
diag::preconcurrency_not_inheritance_clause);
3341-
ty = ErrorType::get(getASTContext());
3342-
} else if (!ty->isConstraintType()) {
3343-
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3344-
diag::preconcurrency_not_existential, ty);
3345-
ty = ErrorType::get(getASTContext());
3346-
}
3332+
if (ty->hasError())
3333+
return ty;
33473334

3348-
// Nothing to record in the type.
3349-
} else {
3335+
if (!options.is(TypeResolverContext::Inherited) ||
3336+
getDeclContext()->getSelfProtocolDecl()) {
33503337
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3351-
diag::preconcurrency_attr_disabled);
3338+
diag::preconcurrency_not_inheritance_clause);
3339+
ty = ErrorType::get(getASTContext());
3340+
} else if (!ty->isConstraintType()) {
3341+
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3342+
diag::preconcurrency_not_existential, ty);
33523343
ty = ErrorType::get(getASTContext());
33533344
}
3345+
3346+
// Nothing to record in the type.
33543347
}
33553348

33563349
if (auto retroactiveAttr = claim<RetroactiveTypeAttr>(attrs)) {

test/ModuleInterface/preconcurrency_conformances.swift

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public protocol WithAssoc {
4444
//--- Client.swift
4545
import A
4646

47-
// CHECK: #if {{.*}} $DynamicActorIsolation
48-
// CHECK-NEXT: @_Concurrency.MainActor public struct GlobalActorTest : @preconcurrency A.P
47+
// CHECK-NOT: #if {{.*}} $DynamicActorIsolation
48+
// CHECK: @_Concurrency.MainActor public struct GlobalActorTest : @preconcurrency A.P
4949

5050
@MainActor
5151
public struct GlobalActorTest : @preconcurrency P {
@@ -56,37 +56,36 @@ public struct GlobalActorTest : @preconcurrency P {
5656
public class ExtTest {
5757
}
5858

59-
// CHECK: #if {{.*}} $DynamicActorIsolation
60-
// CHECK-NEXT: extension Client.ExtTest : @preconcurrency A.P
59+
// CHECK-NOT: #if {{.*}} $DynamicActorIsolation
60+
// CHECK: extension Client.ExtTest : @preconcurrency A.P
6161
extension ExtTest : @preconcurrency P {
6262
public func test() -> Int { 1 }
6363
}
6464

65-
// CHECK: #if {{.*}} && $DynamicActorIsolation
66-
// CHECK-NEXT: public actor ActorTest : @preconcurrency A.P
65+
// CHECK-NOT: #if {{.*}} && $DynamicActorIsolation
66+
// CHECK: public actor ActorTest : @preconcurrency A.P
6767
public actor ActorTest : @preconcurrency P {
6868
public func test() -> Int { 2 }
6969
}
7070

7171
public actor ActorExtTest {
7272
}
7373

74-
// CHECK: #if {{.*}} $DynamicActorIsolation
75-
// CHECK-NEXT: extension Client.ActorExtTest : @preconcurrency A.Q
74+
// CHECK-NOT: #if {{.*}} $DynamicActorIsolation
75+
// CHECK: extension Client.ActorExtTest : @preconcurrency A.Q
7676
extension ActorExtTest : @preconcurrency Q {
7777
public var x: Int { 42 }
7878
}
7979

8080
public struct TestConditional<T> {}
8181

82-
// CHECK: #if {{.*}} $DynamicActorIsolation
83-
// CHECK-NEXT: extension Client.TestConditional : @preconcurrency A.WithAssoc where T == Swift.Int {
82+
// CHECK-NOT: #if {{.*}} $DynamicActorIsolation
83+
// CHECK: extension Client.TestConditional : @preconcurrency A.WithAssoc where T == Swift.Int {
8484
// CHECK-NEXT: @_Concurrency.MainActor public func test() -> T
8585
// CHECK-NEXT: }
8686
extension TestConditional : @preconcurrency WithAssoc where T == Int {
8787
@MainActor public func test() -> T { 42 } // Ok
8888
}
8989

90-
// CHECK: #if {{.*}} $DynamicActorIsolation
91-
// CHECK-NEXT: extension Client.GlobalActorTest : Swift.Sendable {}
92-
// CHECK-NEXT: #endif
90+
// CHECK-NOT: #if {{.*}} $DynamicActorIsolation
91+
// CHECK: extension Client.GlobalActorTest : Swift.Sendable {}

0 commit comments

Comments
 (0)