Skip to content

Commit cfa9905

Browse files
committed
[TypeChecker] Concurrency: Suppress key path sendability diagnostics when InferSendableFromCaptures is enabled
1 parent 40c8da6 commit cfa9905

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3365,18 +3365,21 @@ namespace {
33653365
}
33663366
}
33673367

3368-
// Captured values in a path component must conform to Sendable.
3369-
// These captured values appear in Subscript, such as \Type.dict[k]
3370-
// where k is a captured dictionary key.
3371-
if (auto *args = component.getSubscriptArgs()) {
3372-
for (auto arg : *args) {
3373-
auto type = getType(arg.getExpr());
3374-
if (type &&
3375-
shouldDiagnoseExistingDataRaces(getDeclContext()) &&
3376-
diagnoseNonSendableTypes(
3377-
type, getDeclContext(), component.getLoc(),
3378-
diag::non_sendable_keypath_capture))
3379-
diagnosed = true;
3368+
// With `InferSendableFromCaptures` feature enabled the solver is
3369+
// responsible for inferring `& Sendable` for sendable key paths.
3370+
if (!ctx.LangOpts.hasFeature(Feature::InferSendableFromCaptures)) {
3371+
// Captured values in a path component must conform to Sendable.
3372+
// These captured values appear in Subscript, such as \Type.dict[k]
3373+
// where k is a captured dictionary key.
3374+
if (auto *args = component.getSubscriptArgs()) {
3375+
for (auto arg : *args) {
3376+
auto type = getType(arg.getExpr());
3377+
if (type && shouldDiagnoseExistingDataRaces(getDeclContext()) &&
3378+
diagnoseNonSendableTypes(type, getDeclContext(),
3379+
component.getLoc(),
3380+
diag::non_sendable_keypath_capture))
3381+
diagnosed = true;
3382+
}
33803383
}
33813384
}
33823385
}

0 commit comments

Comments
 (0)