Skip to content

Commit 59ec789

Browse files
committed
[CSApply] Allow @dynamicMemberLookup subscripts to take sendable key path
The changes to support `& Sendable` composition with key path types adjusted `buildKeyPathDynamicMemberArgExpr` to support that but the use-site erroneously still cast index type or `BoundGenericType` as before. Resolves: #75244 Resolves: rdar://131768785
1 parent 1189372 commit 59ec789

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/Sema/CSApply.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -5409,8 +5409,8 @@ namespace {
54095409
auto indexType = getTypeOfDynamicMemberIndex(overload);
54105410
Expr *argExpr = nullptr;
54115411
if (overload.choice.isKeyPathDynamicMemberLookup()) {
5412-
argExpr = buildKeyPathDynamicMemberArgExpr(
5413-
indexType->castTo<BoundGenericType>(), componentLoc, memberLoc);
5412+
argExpr = buildKeyPathDynamicMemberArgExpr(indexType, componentLoc,
5413+
memberLoc);
54145414
} else {
54155415
auto fieldName = overload.choice.getName().getBaseIdentifier().str();
54165416
argExpr = buildDynamicMemberLookupArgExpr(fieldName, componentLoc,

test/attr/attr_dynamic_member_lookup.swift

+7
Original file line numberDiff line numberDiff line change
@@ -833,3 +833,10 @@ public extension S3_54864 {
833833
get { s2_54864_instance[keyPath: member] } // expected-error {{key path with root type 'S3_54864' cannot be applied to a base of type 'S2_54864'}}
834834
}
835835
}
836+
837+
// https://github.com/swiftlang/swift/issues/75244
838+
struct WithSendable {
839+
subscript(dynamicMember member: KeyPath<String, Int> & Sendable) -> Bool { // Ok
840+
get { false }
841+
}
842+
}

0 commit comments

Comments
 (0)