Skip to content

[Foundation] Update hashing for bridged NSError protocols #21056

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

@lorentey lorentey commented Dec 5, 2018

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

@lorentey
Copy link
Member Author

lorentey commented Dec 5, 2018

@swift-ci test

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.
…alue/_rawHashValue

The compiler-synthesized / stdlib-provided default implementations seem perfectly fine for these.
…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.
@lorentey
Copy link
Member Author

Rebased to fix a conflict. I also added a commit that removes the (obsolete and slightly broken) hashValue implementations for CocoaError.Code and URLError.Code -- RawRepresentable provides better default implementations for hashing these.

@lorentey
Copy link
Member Author

@swift-ci please test

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