Skip to content

Commit e177316

Browse files
authored
Merge pull request swiftlang#75348 from DougGregor/isolation-in-unsafe-inherit-downgrade-old-concurrency-lib-6.0
[6.0] Downgrade the error about `#isolation` in `@_unsafeInheritExecutor` when the concurrency library is old
2 parents 6ca5714 + 88c55d8 commit e177316

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3964,6 +3964,20 @@ namespace {
39643964
return nullptr;
39653965
}
39663966

3967+
/// Check whether there are _unsafeInheritExecutor_ workarounds in the
3968+
/// given _Concurrency module.
3969+
static bool hasUnsafeInheritExecutorWorkarounds(
3970+
DeclContext *dc, SourceLoc loc
3971+
) {
3972+
ASTContext &ctx = dc->getASTContext();
3973+
Identifier name =
3974+
ctx.getIdentifier("_unsafeInheritExecutor_withUnsafeContinuation");
3975+
NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions;
3976+
LookupResult lookup = TypeChecker::lookupUnqualified(
3977+
dc, DeclNameRef(name), loc, lookupOptions);
3978+
return !lookup.empty();
3979+
}
3980+
39673981
void recordCurrentContextIsolation(
39683982
CurrentContextIsolationExpr *isolationExpr) {
39693983
// If an actor has already been assigned, we're done.
@@ -3984,6 +3998,12 @@ namespace {
39843998
diag::isolation_in_inherits_executor,
39853999
inDefaultArgument);
39864000
diag.limitBehaviorIf(inConcurrencyModule, DiagnosticBehavior::Warning);
4001+
4002+
if (!inConcurrencyModule &&
4003+
!hasUnsafeInheritExecutorWorkarounds(func, func->getLoc())) {
4004+
diag.limitBehavior(DiagnosticBehavior::Warning);
4005+
}
4006+
39874007
replaceUnsafeInheritExecutorWithDefaultedIsolationParam(func, diag);
39884008
}
39894009

0 commit comments

Comments
 (0)