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

Parity: NSCoder miscellanea #2119

Merged
merged 2 commits into from Apr 17, 2019
Merged

Parity: NSCoder miscellanea #2119

merged 2 commits into from Apr 17, 2019

Conversation

millenomi
Copy link
Contributor

  • Added missing API: DecodingFailurePolicy.raiseException. It is now the default like on Darwin.

  • Match Darwin behavior while decoding if you decode without raising exceptions.

  • decodeTopLevel… variants are noted unavailable on swift-corelibs-foundation, with rationale and replacement directions.

Swift doesn’t have exceptions, and it used to define .setErrorAndReturn as the defaults. However, until very recently failWithError(_:) was unimplemented and trapped with a fatal error, effectively meaning that all coding failures were behaving as if .raiseException was set in a Darwin Swift-only app: by crashing.

Since code written to 4.x-5.0 may be relying on this behavior, we make it explicit and consistent with Darwin: there is now a .raiseException constant, it’s the default, and it fails with a fatal error in failWithError(_:). The new secure initializers (at #2102) set .setErrorAndReturn just like on Darwin, and thus won’t raise and instead just thrown an error.

Tests will be added.

@millenomi
Copy link
Contributor Author

@swift-ci please test

@millenomi
Copy link
Contributor Author

millenomi commented Apr 15, 2019

- Added missing API: `DecodingFailurePolicy.raiseException`. It is now the default like on Darwin.

- Match Darwin behavior while decoding if you decode without raising exceptions.

- `decodeTopLevel…` variants are noted unavailable on swift-corelibs-foundation, with rationale and replacement directions.

Swift doesn’t have exceptions, and it used to define `.setErrorAndReturn` as the defaults. However, until very recently `failWithError(_:)` was unimplemented and trapped with a fatal error, effectively meaning that all coding failures were behaving as if `.raiseException` was set in a Darwin Swift-only app: by crashing.

Since code written to 4.x-5.0 may be relying on this behavior, we make it explicit and consistent with Darwin: there is now a `.raiseException` constant, it’s the default, and it fails with a fatal error in `failWithError(_:)`. The new secure initializers (at #2102) set `.setErrorAndReturn` just like on Darwin, and thus won’t raise and instead just thrown an error.

Tests will be added.
@millenomi
Copy link
Contributor Author

@swift-ci please test and merge

1 similar comment
@millenomi
Copy link
Contributor Author

@swift-ci please test and merge

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.

None yet

2 participants