Skip to content

Commit ef392c1

Browse files
authored
Merge pull request #21056 from lorentey/error-hashing
[Foundation] Update hashing for bridged NSError protocols
2 parents 1f5f6db + 23188af commit ef392c1

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

stdlib/public/Darwin/Foundation/NSError.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,9 @@ extension _BridgedNSError where Self.RawValue: FixedWidthInteger {
406406
self.init(rawValue: RawValue(_bridgedNSError.code))
407407
}
408408

409-
public var hashValue: Int { return _code }
409+
public func hash(into hasher: inout Hasher) {
410+
hasher.combine(_code)
411+
}
410412
}
411413

412414
/// Describes a bridged error that stores the underlying NSError, so
@@ -480,9 +482,9 @@ public extension _BridgedStoredNSError {
480482
}
481483

482484
/// Implementation of Hashable for all _BridgedStoredNSErrors.
483-
public extension _BridgedStoredNSError {
484-
var hashValue: Int {
485-
return _nsError.hashValue
485+
extension _BridgedStoredNSError {
486+
public func hash(into hasher: inout Hasher) {
487+
hasher.combine(_nsError)
486488
}
487489
}
488490

@@ -568,10 +570,6 @@ public struct CocoaError : _BridgedStoredNSError {
568570
public init(rawValue: Int) {
569571
self.rawValue = rawValue
570572
}
571-
572-
public var hashValue: Int {
573-
return self.rawValue
574-
}
575573
}
576574
}
577575

@@ -1799,10 +1797,6 @@ public struct URLError : _BridgedStoredNSError {
17991797
public init(rawValue: Int) {
18001798
self.rawValue = rawValue
18011799
}
1802-
1803-
public var hashValue: Int {
1804-
return self.rawValue
1805-
}
18061800
}
18071801
}
18081802

0 commit comments

Comments
 (0)