@@ -2427,6 +2427,8 @@ namespace {
24272427 }
24282428
24292429 void checkDefaultArgument (DefaultArgumentExpr *expr) {
2430+ getCurrentContextIsolation (expr);
2431+
24302432 // Check the context isolation against the required isolation for
24312433 // evaluating the default argument synchronously. If the default
24322434 // argument must be evaluated asynchronously, record that in the
@@ -3378,13 +3380,8 @@ namespace {
33783380
33793381 // FIXME: CurrentContextIsolationExpr does not have its actor set
33803382 // at this point.
3381- if (auto *macro = dyn_cast<MacroExpansionExpr>(arg)) {
3382- auto *expansion = macro->getRewritten ();
3383- if (auto *isolation = dyn_cast<CurrentContextIsolationExpr>(expansion)) {
3384- recordCurrentContextIsolation (isolation);
3385- arg = isolation->getActor ();
3386- }
3387- }
3383+ if (auto isolation = getCurrentContextIsolation (arg))
3384+ arg = isolation;
33883385
33893386 argForIsolatedParam = arg;
33903387 unsatisfiedIsolation = std::nullopt ;
@@ -3547,6 +3544,25 @@ namespace {
35473544 return false ;
35483545 }
35493546
3547+ Expr *getCurrentContextIsolation (Expr *expr) {
3548+ // Look through caller-side default arguments for #isolation.
3549+ auto *defaultArg = dyn_cast<DefaultArgumentExpr>(expr);
3550+ if (defaultArg && defaultArg->isCallerSide ()) {
3551+ expr = defaultArg->getCallerSideDefaultExpr ();
3552+ }
3553+
3554+ if (auto *macro = dyn_cast<MacroExpansionExpr>(expr)) {
3555+ expr = macro->getRewritten ();
3556+ }
3557+
3558+ if (auto *isolation = dyn_cast<CurrentContextIsolationExpr>(expr)) {
3559+ recordCurrentContextIsolation (isolation);
3560+ return isolation->getActor ();
3561+ }
3562+
3563+ return nullptr ;
3564+ }
3565+
35503566 void recordCurrentContextIsolation (
35513567 CurrentContextIsolationExpr *isolationExpr) {
35523568 // If an actor has already been assigned, we're done.
0 commit comments