Skip to content

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

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

Conversation

itaiferber
Copy link
Contributor

@itaiferber itaiferber commented Jun 30, 2017

What's in this pull request?
Cherry-picks #10728 to swift-4.0-branch.

Explanation: 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

Scope: Affects writers of Encoders/Decoders and consumers of the new Codable API.
Radars:

  • rdar://problem/32512602
  • rdar://problem/32512692

Risk: Low
Testing: Updates existing unit tests to confirm expected behavior.

This PR should not be merged on its own. This must be merged simultaneously with #10728 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

@swift-ci Please test macOS

@itaiferber
Copy link
Contributor Author

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

@swift-ci
Copy link
Contributor

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

@itaiferber
Copy link
Contributor Author

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

@swift-ci
Copy link
Contributor

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

@itaiferber
Copy link
Contributor Author

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

@swift-ci
Copy link
Contributor

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

@itaiferber
Copy link
Contributor Author

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

@itaiferber itaiferber merged commit e0b775d into swiftlang:swift-4.0-branch Jul 1, 2017
@itaiferber itaiferber deleted the 4.0-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.

2 participants