Skip to content

Commit 1baccc2

Browse files
authored
Merge pull request #75347 from DougGregor/isolation-in-unsafe-inherit-downgrade-old-concurrency-lib
Downgrade the error about `#isolation` in `@_unsafeInheritExecutor` when the concurrency library is old
2 parents 439cbe6 + d4ba753 commit 1baccc2

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
@@ -3967,6 +3967,20 @@ namespace {
39673967
return nullptr;
39683968
}
39693969

3970+
/// Check whether there are _unsafeInheritExecutor_ workarounds in the
3971+
/// given _Concurrency module.
3972+
static bool hasUnsafeInheritExecutorWorkarounds(
3973+
DeclContext *dc, SourceLoc loc
3974+
) {
3975+
ASTContext &ctx = dc->getASTContext();
3976+
Identifier name =
3977+
ctx.getIdentifier("_unsafeInheritExecutor_withUnsafeContinuation");
3978+
NameLookupOptions lookupOptions = defaultUnqualifiedLookupOptions;
3979+
LookupResult lookup = TypeChecker::lookupUnqualified(
3980+
dc, DeclNameRef(name), loc, lookupOptions);
3981+
return !lookup.empty();
3982+
}
3983+
39703984
void recordCurrentContextIsolation(
39713985
CurrentContextIsolationExpr *isolationExpr) {
39723986
// If an actor has already been assigned, we're done.
@@ -3987,6 +4001,12 @@ namespace {
39874001
diag::isolation_in_inherits_executor,
39884002
inDefaultArgument);
39894003
diag.limitBehaviorIf(inConcurrencyModule, DiagnosticBehavior::Warning);
4004+
4005+
if (!inConcurrencyModule &&
4006+
!hasUnsafeInheritExecutorWorkarounds(func, func->getLoc())) {
4007+
diag.limitBehavior(DiagnosticBehavior::Warning);
4008+
}
4009+
39904010
replaceUnsafeInheritExecutorWithDefaultedIsolationParam(func, diag);
39914011
}
39924012

0 commit comments

Comments
 (0)