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