-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Use Hashable.hash(into:)
over hashValue
to silence the deprecation warnings
#1820
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
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one major issue with NSObject
's hashing, and lots of smaller nitpicks.
The NSObject
issue isn't new with this PR, but since we're changing it, we might as well change it to something that's consistent with Apple's Foundation.
Foundation/NSObject.swift
Outdated
@@ -323,8 +323,8 @@ open class NSObject : NSObjectProtocol, Equatable, Hashable { | |||
return self | |||
} | |||
|
|||
open var hashValue: Int { | |||
return hash | |||
open func hash(into hasher: inout Hasher) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For compatibility with the Foundation overlay on Cocoa platforms, we should not remove the existing hashValue
definition, but we should make it public final
instead of open
. This also applies tohash(into:)
-- it must also be declared public final
. (See swiftlang/swift#20129)
The NSObject
hashing interface is hash
; subclasses must override that instead of hashValue
or hash(into:)
. Sadly, this includes subclasses defined within this module -- I think there might be a couple of subclasses that do currently the wrong thing.
(On Darwin, NSObject.hashValue
and hash(into:)
are defined public
because the enclosing module is small, and doesn't define subclasses. The appropriate qualifier in swift-corelibs-foundation is public final
.)
Thanks a lot for working on this! The |
@lorentey Thanks for your review and the suggestions! I'll address those. |
Co-Authored-By: ikesyo <[email protected]>
@swift-ci Please test |
We're trying to keep these in sync as much as possible. |
I'll submit a PR to update the Foundation overlay soon -- it makes sense to hold this PR until then. |
@lorentey Is there any progress on the overlay? I'd like to merge this if it needs more time. |
Apologies for the delay. I split out your Switching to |
@swift-ci please test and merge |
There are some remaining warnings, but this should be a good start.