@@ -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