@@ -1921,7 +1921,17 @@ bool swift::diagnoseApplyArgSendability(ApplyExpr *apply, const DeclContext *dec
1921
1921
// Determine the type of the argument, ignoring any implicit
1922
1922
// conversions that could have stripped sendability.
1923
1923
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
+ }
1925
1935
}
1926
1936
}
1927
1937
@@ -2180,8 +2190,10 @@ namespace {
2180
2190
// recieve isolation from its decl context), then the expression cannot
2181
2191
// require a different isolation.
2182
2192
for (auto *dc : contextStack) {
2183
- if (!infersIsolationFromContext(dc))
2193
+ if (!infersIsolationFromContext(dc)) {
2194
+ requiredIsolation.clear();
2184
2195
return false;
2196
+ }
2185
2197
2186
2198
// To refine the required isolation, the existing requirement
2187
2199
// must either be 'nonisolated' or exactly the same as the
@@ -2195,6 +2207,7 @@ namespace {
2195
2207
requiredIsolationLoc,
2196
2208
diag::conflicting_default_argument_isolation,
2197
2209
isolation->second, refinedIsolation);
2210
+ requiredIsolation.clear();
2198
2211
return true;
2199
2212
}
2200
2213
}
@@ -2205,8 +2218,8 @@ namespace {
2205
2218
void checkDefaultArgument(DefaultArgumentExpr *expr) {
2206
2219
// Check the context isolation against the required isolation for
2207
2220
// 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 .
2210
2223
auto requiredIsolation = expr->getRequiredIsolation();
2211
2224
auto contextIsolation = getInnermostIsolatedContext(
2212
2225
getDeclContext(), getClosureActorIsolation);
@@ -2227,10 +2240,7 @@ namespace {
2227
2240
break;
2228
2241
}
2229
2242
2230
- auto &ctx = getDeclContext()->getASTContext();
2231
- ctx.Diags.diagnose(
2232
- expr->getLoc(), diag::isolated_default_argument,
2233
- requiredIsolation, contextIsolation);
2243
+ expr->setImplicitlyAsync();
2234
2244
}
2235
2245
2236
2246
/// Check closure captures for Sendable violations.
0 commit comments