Skip to content

Commit 88c55d8

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 5b50361 commit 88c55d8

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)