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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions stdlib/public/Darwin/Foundation/NSError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,9 @@ extension _BridgedNSError where Self.RawValue: FixedWidthInteger {
self.init(rawValue: RawValue(_bridgedNSError.code))
}

public var hashValue: Int { return _code }
public func hash(into hasher: inout Hasher) {
hasher.combine(_code)
}
}

/// Describes a bridged error that stores the underlying NSError, so
Expand Down Expand Up @@ -480,9 +482,9 @@ public extension _BridgedStoredNSError {
}

/// Implementation of Hashable for all _BridgedStoredNSErrors.
public extension _BridgedStoredNSError {
var hashValue: Int {
return _nsError.hashValue
extension _BridgedStoredNSError {
public func hash(into hasher: inout Hasher) {
hasher.combine(_nsError)
}
}

Expand Down Expand Up @@ -568,10 +570,6 @@ public struct CocoaError : _BridgedStoredNSError {
public init(rawValue: Int) {
self.rawValue = rawValue
}

public var hashValue: Int {
return self.rawValue
}
}
}

Expand Down Expand Up @@ -1799,10 +1797,6 @@ public struct URLError : _BridgedStoredNSError {
public init(rawValue: Int) {
self.rawValue = rawValue
}

public var hashValue: Int {
return self.rawValue
}
}
}

Expand Down