Skip to content

Commit 3a0acf8

Browse files
committed
[AST/Sema] Decouple @preconcurrency conformances from DynamicActorIsolation feature flag
1 parent 03e9d42 commit 3a0acf8

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
@@ -5697,8 +5697,6 @@ ERROR(preconcurrency_not_inheritance_clause,none,
56975697
"'preconcurrency' attribute only applies in inheritance clauses", ())
56985698
ERROR(preconcurrency_not_existential,none,
56995699
"'preconcurrency' attribute cannot apply to non-protocol type %0", (Type))
5700-
ERROR(preconcurrency_attr_disabled,none,
5701-
"attribute requires '-enable-experimental-feature DynamicActorIsolation'", ())
57025700

57035701
ERROR(redundant_any_in_existential,none,
57045702
"redundant 'any' in type %0",

lib/AST/FeatureSet.cpp

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

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

672650
UNINTERESTING_FEATURE(BorrowingSwitch)
673651

lib/Sema/TypeCheckType.cpp

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

33193319
if (auto preconcurrencyAttr = claim<PreconcurrencyTypeAttr>(attrs)) {
3320-
auto &ctx = getASTContext();
3321-
if (ctx.LangOpts.hasFeature(Feature::DynamicActorIsolation)) {
3322-
if (ty->hasError())
3323-
return ty;
3324-
3325-
if (!options.is(TypeResolverContext::Inherited) ||
3326-
getDeclContext()->getSelfProtocolDecl()) {
3327-
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3328-
diag::preconcurrency_not_inheritance_clause);
3329-
ty = ErrorType::get(getASTContext());
3330-
} else if (!ty->isConstraintType()) {
3331-
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3332-
diag::preconcurrency_not_existential, ty);
3333-
ty = ErrorType::get(getASTContext());
3334-
}
3320+
if (ty->hasError())
3321+
return ty;
33353322

3336-
// Nothing to record in the type.
3337-
} else {
3323+
if (!options.is(TypeResolverContext::Inherited) ||
3324+
getDeclContext()->getSelfProtocolDecl()) {
33383325
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3339-
diag::preconcurrency_attr_disabled);
3326+
diag::preconcurrency_not_inheritance_clause);
3327+
ty = ErrorType::get(getASTContext());
3328+
} else if (!ty->isConstraintType()) {
3329+
diagnoseInvalid(repr, preconcurrencyAttr->getAtLoc(),
3330+
diag::preconcurrency_not_existential, ty);
33403331
ty = ErrorType::get(getASTContext());
33413332
}
3333+
3334+
// Nothing to record in the type.
33423335
}
33433336

33443337
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)