Skip to content

[TF] Add Optional: KeyPathIterable conformance. #33992

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

Merged

Conversation

dan-zheng
Copy link
Contributor

Add KeyPathIterable conformances for Optional and Optional.TangentVector.


Unblocks tensorflow/swift-apis#1062.

Add `KeyPathIterable` conformances for `Optional` and `Optional.TangentVector`.
@dan-zheng dan-zheng added the tensorflow This is for "tensorflow" branch PRs. label Sep 18, 2020
@dan-zheng dan-zheng requested a review from efremale September 18, 2020 19:13
@dan-zheng
Copy link
Contributor Author

@swift-ci Please test tensorflow

@dan-zheng
Copy link
Contributor Author

There are some unrelated test failures, to be investigated:

Failing Tests (3):
    Swift(linux-x86_64) :: IDE/complete_unresolved_members.swift
    Swift(linux-x86_64) :: IDE/complete_stmt_controlling_expr.swift
    Swift(linux-x86_64) :: IDE/complete_generic_optional.swift

Merging to unblock progress.

@dan-zheng dan-zheng merged commit 74a17cd into swiftlang:tensorflow Sep 18, 2020
@dan-zheng dan-zheng deleted the optional-key-path-iterable branch September 18, 2020 19:59
dabrahams pushed a commit to google/swift that referenced this pull request Sep 19, 2020
…tage

* 'tensorflow' of github.com:apple/swift:
  [TF] Add `Optional: KeyPathIterable` conformance. (swiftlang#33992)
efremale added a commit to efremale/swift-apis that referenced this pull request Sep 23, 2020
swiftlang/swift#33992 added `Optional: KeyPathIterable` conformance.
The added conformance caused code parts like `self[keyPath: kp] as? _KeyPathIterableBase`
to be interpreted as casting `Optional` (return type of `self[keyPath: kp]`) to
`_KeyPathIterableBase` (which always succeeds because of the added conformance).

The original intention was to cast the wrapped value of `Optional` to `_KeyPathIterableBase`.
This original behavior is restored by changing
`if let nested = self[keyPath: kp] as? _KeyPathIterableBase` to
`if let value = self[keyPath: kp], let nested = value as? _KeyPathIterableBase`,
where `value` first "unwraps" `Optional` and `nested` is the result of casting wrapped
value to `_KeyPathIterableBase`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tensorflow This is for "tensorflow" branch PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant