[SR-12763] KeyPath - missing appending(path:)
overload
#55208
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Additional Detail from JIRA
md5: 78e1537f38780be91636073073c60f26
Issue Description:
The `KeyPath<,>` is missing an `appending(path: )` overload that allows a `PartialKeyPath<>` to be appended and return a non-optional `PartialKeyPath<T>` type.
This is the missing function signature:
`KeyPath<U, T>.appending(path: PartialKeyPath<T>) -> PartialKeyPath<T>`
Currently, to work around this limitation you need to cast the `KeyPath<,>` to `AnyKeyPath` before appending the `PartialKeyPath<>`, and it returns an optional. The following code should work, but it does not compile.
```swift
{ var category: Category }
{ var id: UUID var name: String }
{ let head: KeyPath<Product, Category> = \Product.category let tail: PartialKeyPath<Category> = \Category.name let value: Any = head.appending(path: tail) }
```
This is result of this discussion: https://forums.swift.org/t/appending-partialkeypath-to-keypath/36283/4
The text was updated successfully, but these errors were encountered: