Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-12763] KeyPath - missing appending(path:) overload #55208

Open
swift-ci opened this issue May 9, 2020 · 1 comment
Open

[SR-12763] KeyPath - missing appending(path:) overload #55208

swift-ci opened this issue May 9, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 9, 2020

Previous ID SR-12763
Radar None
Original Reporter adam-26 (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug
Assignee None
Priority Medium

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

**struct** Product

{ var category: Category }

**struct** Category

{ var id: UUID var name: String }

**func** example()

{ 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

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@vidugloeck
Copy link

According to the discussion thread, the missing signature is:

KeyPath<Root, T>.appending(path: PartialKeyPath<T>) -> PartialKeyPath<Root>

Could we update this issue? I am also happy to create a new one, if that is more suitable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants