Skip to content

Commit d4ba753

Browse files
committed
Downgrade the error about #isolation in @_unsafeInheritExecutor when the concurrency library is old
The introduction of the error concerning use of `#isolation` within an `@_unsafeInheritExecutor` function was carefully staged between the concurrency library and compiler to avoid breaking source compatibility. However, it is a source compatibility break when dealing certain revisions of the concurrency library that adopted `#isolation` prior to the compiler error. Detect when the _Concurrency library doesn't have the necessary workarounds in it and downgrade the error to a warning. Fixes rdar://132023573.
1 parent 8e6feff commit d4ba753

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)