@@ -1958,7 +1958,17 @@ bool swift::diagnoseApplyArgSendability(ApplyExpr *apply, const DeclContext *dec
19581958 // Determine the type of the argument, ignoring any implicit
19591959 // conversions that could have stripped sendability.
19601960 if (Expr *argExpr = arg.getExpr ()) {
1961- argType = argExpr->findOriginalType ();
1961+ argType = argExpr->findOriginalType ();
1962+
1963+ // If this is a default argument expression, don't check Sendability
1964+ // if the argument is evaluated in the callee's isolation domain.
1965+ if (auto *defaultExpr = dyn_cast<DefaultArgumentExpr>(argExpr)) {
1966+ auto argIsolation = defaultExpr->getRequiredIsolation ();
1967+ auto calleeIsolation = isolationCrossing->getCalleeIsolation ();
1968+ if (argIsolation == calleeIsolation) {
1969+ continue ;
1970+ }
1971+ }
19621972 }
19631973 }
19641974
@@ -2217,8 +2227,10 @@ namespace {
22172227 // recieve isolation from its decl context), then the expression cannot
22182228 // require a different isolation.
22192229 for (auto *dc : contextStack) {
2220- if (!infersIsolationFromContext (dc))
2230+ if (!infersIsolationFromContext (dc)) {
2231+ requiredIsolation.clear ();
22212232 return false ;
2233+ }
22222234
22232235 // To refine the required isolation, the existing requirement
22242236 // must either be 'nonisolated' or exactly the same as the
@@ -2232,6 +2244,7 @@ namespace {
22322244 requiredIsolationLoc,
22332245 diag::conflicting_default_argument_isolation,
22342246 isolation->second , refinedIsolation);
2247+ requiredIsolation.clear ();
22352248 return true ;
22362249 }
22372250 }
@@ -2242,8 +2255,8 @@ namespace {
22422255 void checkDefaultArgument (DefaultArgumentExpr *expr) {
22432256 // Check the context isolation against the required isolation for
22442257 // evaluating the default argument synchronously. If the default
2245- // argument must be evaluated asynchronously, it must be written
2246- // explicitly in the argument list with 'await' .
2258+ // argument must be evaluated asynchronously, record that in the
2259+ // expression node .
22472260 auto requiredIsolation = expr->getRequiredIsolation ();
22482261 auto contextIsolation = getInnermostIsolatedContext (
22492262 getDeclContext (), getClosureActorIsolation);
@@ -2264,10 +2277,7 @@ namespace {
22642277 break ;
22652278 }
22662279
2267- auto &ctx = getDeclContext ()->getASTContext ();
2268- ctx.Diags .diagnose (
2269- expr->getLoc (), diag::isolated_default_argument,
2270- requiredIsolation, contextIsolation);
2280+ expr->setImplicitlyAsync ();
22712281 }
22722282
22732283 // / Check closure captures for Sendable violations.
0 commit comments