@@ -1921,7 +1921,17 @@ bool swift::diagnoseApplyArgSendability(ApplyExpr *apply, const DeclContext *dec
19211921 // Determine the type of the argument, ignoring any implicit
19221922 // conversions that could have stripped sendability.
19231923 if (Expr *argExpr = arg.getExpr ()) {
1924- argType = argExpr->findOriginalType ();
1924+ argType = argExpr->findOriginalType ();
1925+
1926+ // If this is a default argument expression, don't check Sendability
1927+ // if the argument is evaluated in the callee's isolation domain.
1928+ if (auto *defaultExpr = dyn_cast<DefaultArgumentExpr>(argExpr)) {
1929+ auto argIsolation = defaultExpr->getRequiredIsolation ();
1930+ auto calleeIsolation = isolationCrossing->getCalleeIsolation ();
1931+ if (argIsolation == calleeIsolation) {
1932+ continue ;
1933+ }
1934+ }
19251935 }
19261936 }
19271937
@@ -2180,8 +2190,10 @@ namespace {
21802190 // recieve isolation from its decl context), then the expression cannot
21812191 // require a different isolation.
21822192 for (auto *dc : contextStack) {
2183- if (!infersIsolationFromContext (dc))
2193+ if (!infersIsolationFromContext (dc)) {
2194+ requiredIsolation.clear ();
21842195 return false ;
2196+ }
21852197
21862198 // To refine the required isolation, the existing requirement
21872199 // must either be 'nonisolated' or exactly the same as the
@@ -2195,6 +2207,7 @@ namespace {
21952207 requiredIsolationLoc,
21962208 diag::conflicting_default_argument_isolation,
21972209 isolation->second , refinedIsolation);
2210+ requiredIsolation.clear ();
21982211 return true ;
21992212 }
22002213 }
@@ -2205,8 +2218,8 @@ namespace {
22052218 void checkDefaultArgument (DefaultArgumentExpr *expr) {
22062219 // Check the context isolation against the required isolation for
22072220 // evaluating the default argument synchronously. If the default
2208- // argument must be evaluated asynchronously, it must be written
2209- // explicitly in the argument list with 'await' .
2221+ // argument must be evaluated asynchronously, record that in the
2222+ // expression node .
22102223 auto requiredIsolation = expr->getRequiredIsolation ();
22112224 auto contextIsolation = getInnermostIsolatedContext (
22122225 getDeclContext (), getClosureActorIsolation);
@@ -2227,10 +2240,7 @@ namespace {
22272240 break ;
22282241 }
22292242
2230- auto &ctx = getDeclContext ()->getASTContext ();
2231- ctx.Diags .diagnose (
2232- expr->getLoc (), diag::isolated_default_argument,
2233- requiredIsolation, contextIsolation);
2243+ expr->setImplicitlyAsync ();
22342244 }
22352245
22362246 // / Check closure captures for Sendable violations.
0 commit comments