Skip to content

Commit 2ca3c73

Browse files
authored
Merge pull request #37022 from DougGregor/builtin-executor-feature-5.5
[5.5] [Concurrency] Put Builtin.Executor type behind a feature flag.
2 parents 73a7b53 + 2117031 commit 2ca3c73

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

include/swift/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ LANGUAGE_FEATURE(RethrowsProtocol, 0, "@rethrows protocol", true)
4343
LANGUAGE_FEATURE(GlobalActors, 0, "Global actors", langOpts.EnableExperimentalConcurrency)
4444
LANGUAGE_FEATURE(BuiltinJob, 0, "Builtin.Job type", true)
4545
LANGUAGE_FEATURE(Sendable, 0, "Sendable and @Sendable", true)
46+
LANGUAGE_FEATURE(BuiltinExecutor, 0, "Executor builtins", true)
4647
LANGUAGE_FEATURE(BuiltinContinuation, 0, "Continuation builtins", true)
4748
LANGUAGE_FEATURE(BuiltinTaskGroup, 0, "TaskGroup builtins", true)
4849

lib/AST/ASTPrinter.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2745,6 +2745,35 @@ static bool usesFeatureBuiltinJob(Decl *decl) {
27452745
return false;
27462746
}
27472747

2748+
static bool usesFeatureBuiltinExecutor(Decl *decl) {
2749+
auto typeHasBuiltinExecutor = [](Type type) {
2750+
return type.findIf([&](Type type) {
2751+
if (auto builtinTy = type->getAs<BuiltinType>())
2752+
return builtinTy->getBuiltinTypeKind()
2753+
== BuiltinTypeKind::BuiltinExecutor;
2754+
2755+
return false;
2756+
});
2757+
};
2758+
2759+
if (auto value = dyn_cast<ValueDecl>(decl)) {
2760+
if (Type type = value->getInterfaceType()) {
2761+
if (typeHasBuiltinExecutor(type))
2762+
return true;
2763+
}
2764+
}
2765+
2766+
if (auto patternBinding = dyn_cast<PatternBindingDecl>(decl)) {
2767+
for (unsigned idx : range(patternBinding->getNumPatternEntries())) {
2768+
if (Type type = patternBinding->getPattern(idx)->getType())
2769+
if (typeHasBuiltinExecutor(type))
2770+
return true;
2771+
}
2772+
}
2773+
2774+
return false;
2775+
}
2776+
27482777
static bool usesFeatureBuiltinContinuation(Decl *decl) {
27492778
return false;
27502779
}

0 commit comments

Comments
 (0)