Open
Description
Description
If a dynamic member subscript is limited to sendable key paths, this check is only performed when invoking the dynamic member directly.
Reproduction
@dynamicMemberLookup
struct S<T> {
subscript<U>(dynamicMember keyPath: KeyPath<T, U> & Sendable) -> U {
fatalError()
}
}
public struct Foo {
subscript<T>(bar bar: T) -> Int { 42 }
}
public struct NonSendable: Hashable {}
func f() {
let s = S<Foo>()
s[dynamicMember: \.[bar: NonSendable()]] // ❌ Fails to compile
s[bar: NonSendable()] // ✅ Compiles when it shouldn't
}
Expected behavior
I expect both lines to fail to compiles.
Environment
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0
Additional information
No response