Skip to content

Make coding paths non-optional [DO NOT MERGE] #10728

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
merged 1 commit into from
Jul 1, 2017

Conversation

itaiferber
Copy link
Contributor

@itaiferber itaiferber commented Jun 30, 2017

What's in this pull request?
As laid out in a proposed update to SE-0166 and SE-0167, there are changes to unkeyed containers and coding paths that we want to introduce to the Codable API. This implements the remainder of those updates which had not yet been implemented:

  • For the benefit of unkeyed containers, coding paths currently contain optional CodingKeys — unkeyed containers are allowed to report a nil key in a path. However, this is unhelpful for debugging purposes, or inspecting the coding path for context, since any unkeyed container simply reports nil, whether it’s at index 1 or 1000

    Now all containers are required to report a non-optional CodingKey for their segment of the coding path, and coding paths are now exposed as [CodingKey]

  • To support this, UnkeyedEncodingContainers now expose their count and UnkeyedDecodingContainers expose their currentIndex

This PR should not be merged on its own. This must be merged simultaneously with #10729 and swiftlang/swift-corelibs-foundation#1091 to avoid breaking the build.

For the benefit of unkeyed containers, coding paths currently contain optional `CodingKey`s — unkeyed containers are allowed to report a `nil` key in a path. However, this is unhelpful for debugging purposes, or inspecting the coding path for context, since any unkeyed container simply reports `nil`, whether it’s at index 1 or 1000.

Now all containers are required to report a non-optional CodingKey for their segment of the coding path, and coding paths are now exposed as `[CodingKey]`.
@itaiferber
Copy link
Contributor Author

swiftlang/swift-corelibs-foundation#1091
@swift-ci Please test Linux

@itaiferber
Copy link
Contributor Author

@swift-ci Please test macOS

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - e1007a2
Test requested by - @itaiferber

@itaiferber
Copy link
Contributor Author

swiftlang/swift-corelibs-foundation#1091
@swift-ci Please test Linux

Copy link
Contributor

@phausler phausler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks pretty mechanical, the change set seems sensible to me

@itaiferber itaiferber merged commit a8ba077 into swiftlang:master Jul 1, 2017
@itaiferber itaiferber deleted the non-optional-coding-paths branch July 1, 2017 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants