Skip to content

[5.0][Foundation] Update hashing for bridged NSError protocols #21205

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 3 commits into from
Dec 11, 2018

Conversation

lorentey
Copy link
Member

(Cherry-picked from #21056, reviewed by @jrose-apple and @DougGregor)

Protocols that wish to provide a default implementation of hashing should do so by providing a hash(into:) implementation. hashValue has been deprecated as a Hashable requirement in SE-0206.

Protocol extensions that only implement hashValue force hashValue-based synthesis on conforming types by default, which will probably produce deprecation warnings soon.

Add missing Hashable requirements to _BridgedNSError and _BridgedStoredNSError.

It is important to add these extensions now, since the presence/absence of defaulted Hashable requirements can cause ABI headaches down the road for conforming types, and these protocols are used by ClangImporter involved in automatic conformance synthesis.

rdar://problem/46496484

Protocols in resilient libraries that wish to provide a default implementation of hashing need to do so by providing a hash(into:) implementation.

hashValue has been deprecated as a Hashable requirement in SE-0206. Implementing only it in a protocol extension curses conforming types to get deprecation warnings by default.

(cherry picked from commit bbaec3d)
…alue/_rawHashValue

The compiler-synthesized / stdlib-provided default implementations seem perfectly fine for these.

(cherry picked from commit 21d31ea)
…ntation

These implementations did not produce the same hash values as the raw value. RawRepresentable provides a correct hashing implementation by default, so let’s just use that.

(cherry picked from commit 23188af)
@lorentey lorentey requested a review from a team as a code owner December 11, 2018 13:27
@lorentey
Copy link
Member Author

@swift-ci please test

@lorentey
Copy link
Member Author

cc @airspeedswift

@airspeedswift airspeedswift merged commit e5f1450 into swiftlang:swift-5.0-branch Dec 11, 2018
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