Skip to content

Make NSObject.hashValue non-overridable #1850

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
Jan 30, 2019

Conversation

lorentey
Copy link
Member

This is cherry picked from @ikesyo's PR #1820 (commit 9ee6b02).

This PR fixes an NSObject API inconsistency between Swift 5's SDK overlays on Darwin and swift-corelibs-foundation. It also fixes several NSObject subclasses to customize hashing through the correct API, NSObject.hash.

NSObject.hashValue is currently declared open, which matches Darwin SDK overlays in Swift 4.2 and below. Unfortunately, hashValue was never supposed to be overridden -- NSObject subclasses are expected to customize hashing by overriding NSObject.hash, which is a distinct property. To help clear up the confusion resulting from this subtle gotcha, last year we decided to change NSObject.hashValue to be non-overridable.

@lorentey
Copy link
Member Author

@swift-ci please test

@ikesyo
Copy link
Member

ikesyo commented Jan 26, 2019

Thanks for cherry-picking it.

@parkera
Copy link
Contributor

parkera commented Jan 29, 2019

Thanks @lorentey

@ianpartridge
Copy link
Contributor

@swift-ci test and merge

@swift-ci swift-ci merged commit bfe8182 into swiftlang:master Jan 30, 2019
@ianpartridge
Copy link
Contributor

Thanks @lorentey - would you like to cherry-pick this to swift-5.0-branch?

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.

5 participants