Appending a writable/sendable key path loses writability
Description
The new sendable key path diagnostics seems to lose writability when appending a sendable, writable key path.
Reproduction
struct S {
var p = 0
}
struct T {
var s = S()
}
func f() {
let kp1: WritableKeyPath<T, S> & Sendable = \T.s
let kp2: WritableKeyPath<T, Int> & Sendable = kp1.appending(path: \.p)
}
Expected behavior
kp2 should compile, but we get:
Error: Cannot convert value of type 'KeyPath<T, Int>' to specified type 'WritableKeyPath<T, Int>'
Environment
swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1) Target: arm64-apple-macosx14.0
Additional information
No response
@xedin Another one. Sorry! 🙈
I think this is a stdlib problem, we discussed this in the proposal - https://github.com/swiftlang/swift-evolution/blob/main/proposals/0418-inferring-sendable-for-methods.md#extending-key-path-merging-functionality-to-preserve-sendability.
Also thank you for the reports, no need to be sorry!