Skip to content

Commit e7d7585

Browse files
committed
Add a feature for global actors & module interface support
1 parent f21c609 commit e7d7585

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol", true)
4040
LANGUAGE_FEATURE(Actors, 0, "actors", langOpts.EnableExperimentalConcurrency)
4141
LANGUAGE_FEATURE(ConcurrentFunctions, 0, "@concurrent functions", true)
4242
LANGUAGE_FEATURE(RethrowsProtocol, 0, "@rethrows protocol", true)
43+
LANGUAGE_FEATURE(GlobalActors, 0, "Global actors", langOpts.EnableExperimentalConcurrency)
4344

4445
#undef LANGUAGE_FEATURE

lib/AST/ASTPrinter.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,6 +2562,21 @@ static bool usesFeatureRethrowsProtocol(Decl *decl) {
25622562
return usesFeatureRethrowsProtocol(decl, checked);
25632563
}
25642564

2565+
static bool usesFeatureGlobalActors(Decl *decl) {
2566+
if (auto nominal = dyn_cast<NominalTypeDecl>(decl)) {
2567+
if (nominal->getAttrs().hasAttribute<GlobalActorAttr>())
2568+
return true;
2569+
}
2570+
2571+
if (auto ext = dyn_cast<ExtensionDecl>(decl)) {
2572+
if (auto nominal = ext->getExtendedNominal())
2573+
if (usesFeatureGlobalActors(nominal))
2574+
return true;
2575+
}
2576+
2577+
return false;
2578+
}
2579+
25652580
/// Determine the set of "new" features used on a given declaration.
25662581
///
25672582
/// Note: right now, all features we check for are "new". At some point, we'll

test/ModuleInterface/features.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ extension Array: FeatureTest.MP where Element : FeatureTest.MP { }
8787
extension OldSchool: UnsafeConcurrentValue { }
8888
// CHECK-NEXT: }
8989

90+
// CHECK: #if compiler(>=5.3) && $GlobalActors
91+
// CHECK-NEXT: @globalActor public struct SomeGlobalActor
92+
@globalActor
93+
public struct SomeGlobalActor {
94+
public static let shared = MyActor()
95+
}
96+
97+
9098
// CHECK: #if compiler(>=5.3) && $AsyncAwait
9199
// CHECK-NEXT: func runSomethingSomewhere
92100
// CHECK-NEXT: #endif

0 commit comments

Comments
 (0)