@@ -600,6 +600,9 @@ static void addSendableFixIt(
600600static bool shouldDiagnoseExistingDataRaces (const DeclContext *dc) {
601601 return contextRequiresStrictConcurrencyChecking (dc, [](const AbstractClosureExpr *) {
602602 return Type ();
603+ },
604+ [](const ClosureExpr *closure) {
605+ return closure->isIsolatedByPreconcurrency ();
603606 });
604607}
605608
@@ -3972,7 +3975,8 @@ void swift::checkOverrideActorIsolation(ValueDecl *value) {
39723975
39733976bool swift::contextRequiresStrictConcurrencyChecking (
39743977 const DeclContext *dc,
3975- llvm::function_ref<Type(const AbstractClosureExpr *)> getType) {
3978+ llvm::function_ref<Type(const AbstractClosureExpr *)> getType,
3979+ llvm::function_ref<bool(const ClosureExpr *)> isolatedByPreconcurrency) {
39763980 switch (dc->getASTContext ().LangOpts .StrictConcurrencyLevel ) {
39773981 case StrictConcurrency::Complete:
39783982 return true ;
@@ -3993,7 +3997,7 @@ bool swift::contextRequiresStrictConcurrencyChecking(
39933997
39943998 // Don't take any more cues if this only got its type information by
39953999 // being provided to a `@preconcurrency` operation.
3996- if (explicitClosure-> isIsolatedByPreconcurrency ( )) {
4000+ if (isolatedByPreconcurrency (explicitClosure )) {
39974001 dc = dc->getParent ();
39984002 continue ;
39994003 }
@@ -4551,11 +4555,13 @@ static bool hasKnownUnsafeSendableFunctionParams(AbstractFunctionDecl *func) {
45514555
45524556Type swift::adjustVarTypeForConcurrency (
45534557 Type type, VarDecl *var, DeclContext *dc,
4554- llvm::function_ref<Type(const AbstractClosureExpr *)> getType) {
4558+ llvm::function_ref<Type(const AbstractClosureExpr *)> getType,
4559+ llvm::function_ref<bool(const ClosureExpr *)> isolatedByPreconcurrency) {
45554560 if (!var->preconcurrency ())
45564561 return type;
45574562
4558- if (contextRequiresStrictConcurrencyChecking (dc, getType))
4563+ if (contextRequiresStrictConcurrencyChecking (
4564+ dc, getType, isolatedByPreconcurrency))
45594565 return type;
45604566
45614567 bool isLValue = false ;
@@ -4676,9 +4682,11 @@ AnyFunctionType *swift::adjustFunctionTypeForConcurrency(
46764682 AnyFunctionType *fnType, ValueDecl *decl, DeclContext *dc,
46774683 unsigned numApplies, bool isMainDispatchQueue,
46784684 llvm::function_ref<Type(const AbstractClosureExpr *)> getType,
4685+ llvm::function_ref<bool(const ClosureExpr *)> isolatedByPreconcurrency,
46794686 llvm::function_ref<Type(Type)> openType) {
46804687 // Apply unsafe concurrency features to the given function type.
4681- bool strictChecking = contextRequiresStrictConcurrencyChecking (dc, getType);
4688+ bool strictChecking = contextRequiresStrictConcurrencyChecking (
4689+ dc, getType, isolatedByPreconcurrency);
46824690 fnType = applyUnsafeConcurrencyToFunctionType (
46834691 fnType, decl, strictChecking, numApplies, isMainDispatchQueue);
46844692
@@ -4738,7 +4746,10 @@ bool swift::completionContextUsesConcurrencyFeatures(const DeclContext *dc) {
47384746 return contextRequiresStrictConcurrencyChecking (
47394747 dc, [](const AbstractClosureExpr *) {
47404748 return Type ();
4741- });
4749+ },
4750+ [](const ClosureExpr *closure) {
4751+ return closure->isIsolatedByPreconcurrency ();
4752+ });
47424753}
47434754
47444755AbstractFunctionDecl const *swift::isActorInitOrDeInitContext (
@@ -4847,6 +4858,9 @@ static ActorIsolation getActorIsolationForReference(
48474858 fromDC,
48484859 [](const AbstractClosureExpr *closure) {
48494860 return closure->getType ();
4861+ },
4862+ [](const ClosureExpr *closure) {
4863+ return closure->isIsolatedByPreconcurrency ();
48504864 })) {
48514865 declIsolation = ActorIsolation::forGlobalActor (
48524866 declIsolation.getGlobalActor (), /* unsafe=*/ false );
0 commit comments