@@ -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,19 +3380,8 @@ namespace {
33783380
33793381 // FIXME: CurrentContextIsolationExpr does not have its actor set
33803382 // at this point.
3381- if (auto *defaultArg = dyn_cast<DefaultArgumentExpr>(arg)) {
3382- // Look through caller-side default arguments for #isolation.
3383- if (defaultArg->isCallerSide ()) {
3384- arg = defaultArg->getCallerSideDefaultExpr ();
3385- }
3386- }
3387- if (auto *macro = dyn_cast<MacroExpansionExpr>(arg)) {
3388- auto *expansion = macro->getRewritten ();
3389- if (auto *isolation = dyn_cast<CurrentContextIsolationExpr>(expansion)) {
3390- recordCurrentContextIsolation (isolation);
3391- arg = isolation->getActor ();
3392- }
3393- }
3383+ if (auto isolation = getCurrentContextIsolation (arg))
3384+ arg = isolation;
33943385
33953386 argForIsolatedParam = arg;
33963387 unsatisfiedIsolation = std::nullopt ;
@@ -3553,6 +3544,25 @@ namespace {
35533544 return false ;
35543545 }
35553546
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+
35563566 void recordCurrentContextIsolation (
35573567 CurrentContextIsolationExpr *isolationExpr) {
35583568 // If an actor has already been assigned, we're done.
0 commit comments