@@ -149,13 +149,12 @@ public class RuntimeError: Error, Hashable, CustomStringConvertible {
149149 }
150150 }
151151
152- public var hashValue : Int {
153- var res = 0
152+ public func hash( into hasher: inout Hasher ) {
154153 for irritant in self . irritants {
155- res = res &* 31 &+ irritant . hashValue
154+ hasher . combine ( irritant )
156155 }
157- res = res &* 31 &+ self . descriptor. hashValue
158- return res &* 31 &+ self . pos. hashValue
156+ hasher . combine ( self . descriptor)
157+ hasher . combine ( self . pos)
159158 }
160159
161160 public var message : String {
@@ -554,37 +553,40 @@ public enum ErrorDescriptor: Hashable {
554553 }
555554 }
556555
557- public var hashValue : Int {
556+ public func hash ( into hasher : inout Hasher ) {
558557 switch self {
559558 case . lexical( let error) :
560- return error . hashValue &* 31
559+ hasher . combine ( error )
561560 case . syntax( let error) :
562- return error. hashValue &* 31 &+ 1
561+ hasher. combine ( 1 )
562+ hasher. combine ( error)
563563 case . type( let found, let expected) :
564- return ( found. hashValue &* 31 &+ expected. hashValue) &* 31 &+ 2
564+ hasher. combine ( 2 )
565+ hasher. combine ( found)
566+ hasher. combine ( expected)
565567 case . range( let fun, let argn, let low, let high) :
566- var res = ( low. hashValue &* 31 &+ high. hashValue) &* 31
567- if let fun = fun {
568- res = ( res + fun. hashValue) &* 31
569- }
570- if let argn = argn {
571- res = ( res + argn. hashValue) &* 31
572- }
573- return res &+ 3
568+ hasher. combine ( 3 )
569+ hasher. combine ( fun)
570+ hasher. combine ( argn)
571+ hasher. combine ( low)
572+ hasher. combine ( high)
574573 case . argumentCount( let fun, let min, let max) :
575- var res = ( min. hashValue &* 31 &+ max. hashValue) &* 31
576- if let fun = fun {
577- res = ( res + fun. hashValue) &* 31
578- }
579- return res &+ 4
574+ hasher. combine ( 4 )
575+ hasher. combine ( fun)
576+ hasher. combine ( min)
577+ hasher. combine ( max)
580578 case . eval( let error) :
581- return error. hashValue &* 31 &+ 5
579+ hasher. combine ( 5 )
580+ hasher. combine ( error)
582581 case . os( let error) :
583- return error. hashValue &* 31 &+ 6
582+ hasher. combine ( 6 )
583+ hasher. combine ( error)
584584 case . abortion:
585- return 7
585+ hasher . combine ( 7 )
586586 case . custom( let kind, let message) :
587- return ( kind. hashValue &* 31 &+ message. hashValue) &* 31 &+ 8
587+ hasher. combine ( 8 )
588+ hasher. combine ( kind)
589+ hasher. combine ( message)
588590 }
589591 }
590592
0 commit comments