-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support Swift 4.2 Hashable #2115
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
@spevans Can you test this please? |
@@ -137,9 +137,15 @@ public struct Date : ReferenceConvertible, Comparable, Equatable { | |||
*/ | |||
public static let distantPast = Date(timeIntervalSinceReferenceDate: -63114076800.0) | |||
|
|||
#if swift(>=4.2) |
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.
The swift
version check should not be needed as there is a branch per version.
public func hash(into hasher: inout Hasher) { | ||
unit.hash(into: &hasher) | ||
value.hash(into: &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.
I dont see this method on Darwin's Foundation (unless its in the latest beta?)
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.
If you don't implement func hash(into hasher: inout Hasher)
it uses hashValue
as a fallback implementation, which on Darwin is just the NSObject
hash.
Could you add a testcase just calling the method for each of the types are modifying please |
cc @lorentey who was already working on this, or similar. |
I suggest to hold this; this is somewhat trickier than it looks, and it has to be synced with the Foundation overlay. In swiftlang/swift#23832, I submitted a draft PR for the overlay parts; I'm preparing a similar PR for corelibs-foundation, too. |
Update: My corelibs-foundation PR is up at #2118. |
@colemancda thank you for the contribution — I'm gonna close this because it has been superseded by #2118. |
Ok, if this is done better somewhere else, that's great. |
Updates implementation of
Hashable
in Foundation types to properly support Swift 4.2 and 5.