Skip to content

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

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?
Applies swiftlang/swift#10728 to swift-corelibs-foundation.

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 in simultaneously with swiftlang/swift#10728 and swiftlang/swift#10728 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 itaiferber force-pushed the non-optional-coding-paths branch from 84e4d3d to 7d0410b Compare June 30, 2017 20:56
@itaiferber itaiferber merged commit 379f28b 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.

1 participant