Skip to content

Commit 2771eb5

Browse files
fix warnings
1 parent 86e4467 commit 2771eb5

17 files changed

+77
-7
lines changed

stdlib/private/StdlibCollectionUnittest/CheckCollectionInstance.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public func checkOneLevelOfForwardCollection<
467467
}
468468
}
469469

470-
var allIndices = Array(collection.indices)
470+
let allIndices = Array(collection.indices)
471471

472472
if expectedArray.count >= 2 {
473473
for i in 0..<allIndices.count-1 {
@@ -693,7 +693,7 @@ public func checkOneLevelOfBidirectionalCollection<
693693
}
694694
}
695695

696-
var allIndices = Array(collection.indices)
696+
let allIndices = Array(collection.indices)
697697

698698
if expectedArray.count >= 2 {
699699
for i in 0..<allIndices.count-1 {
@@ -978,7 +978,7 @@ public func checkOneLevelOfRandomAccessCollection<
978978
}
979979
}
980980

981-
var allIndices = Array(collection.indices)
981+
let allIndices = Array(collection.indices)
982982

983983
if expectedArray.count >= 2 {
984984
for i in 0..<allIndices.count-1 {
@@ -1237,7 +1237,7 @@ public func checkOneLevelOfForwardCollection<
12371237
}
12381238
}
12391239

1240-
var allIndices = Array(collection.indices)
1240+
let allIndices = Array(collection.indices)
12411241

12421242
if expectedArray.count >= 2 {
12431243
for i in 0..<allIndices.count-1 {
@@ -1463,7 +1463,7 @@ public func checkOneLevelOfBidirectionalCollection<
14631463
}
14641464
}
14651465

1466-
var allIndices = Array(collection.indices)
1466+
let allIndices = Array(collection.indices)
14671467

14681468
if expectedArray.count >= 2 {
14691469
for i in 0..<allIndices.count-1 {
@@ -1748,7 +1748,7 @@ public func checkOneLevelOfRandomAccessCollection<
17481748
}
17491749
}
17501750

1751-
var allIndices = Array(collection.indices)
1751+
let allIndices = Array(collection.indices)
17521752

17531753
if expectedArray.count >= 2 {
17541754
for i in 0..<allIndices.count-1 {

stdlib/public/Darwin/Foundation/AffineTransform.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ public struct AffineTransform : ReferenceConvertible, Hashable, CustomStringConv
275275
newSize.height = (m12 * size.width) + (m22 * size.height)
276276
return newSize
277277
}
278+
279+
public func hash(into hasher: inout Hasher) {
280+
hasher.combine(m11)
281+
hasher.combine(m12)
282+
hasher.combine(m21)
283+
hasher.combine(m22)
284+
hasher.combine(tX)
285+
hasher.combine(tY)
286+
}
278287

279288
public var hashValue : Int {
280289
return Int(m11 + m12 + m21 + m22 + tX + tY)

stdlib/public/Darwin/Foundation/Calendar.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,10 @@ public struct Calendar : Hashable, Equatable, ReferenceConvertible, _MutableBoxi
899899

900900
// MARK: -
901901

902+
public func hash(into hasher: inout Hasher) {
903+
hasher.combine(_handle.map { $0 })
904+
}
905+
902906
public var hashValue : Int {
903907
// We implement hash ourselves, because we need to make sure autoupdating calendars have the same hash
904908
if _autoupdating {

stdlib/public/Darwin/Foundation/Date.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public struct Date : ReferenceConvertible, Comparable, Equatable {
141141
The distant past is in terms of centuries.
142142
*/
143143
public static let distantPast = Date(timeIntervalSinceReferenceDate: -63114076800.0)
144+
145+
public func hash(into hasher: inout Hasher) {
146+
hasher.combine(_time)
147+
}
144148

145149
public var hashValue: Int {
146150
if #available(macOS 10.12, iOS 10.0, *) {

stdlib/public/Darwin/Foundation/DateComponents.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@ public struct DateComponents : ReferenceConvertible, Hashable, Equatable, _Mutab
262262
}
263263

264264
// MARK: -
265+
266+
public func hash(into hasher: inout Hasher) {
267+
hasher.combine(_handle.map { $0 })
268+
}
265269

266270
public var hashValue : Int {
267271
return _handle.map { $0.hash }

stdlib/public/Darwin/Foundation/DateInterval.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public struct DateInterval : ReferenceConvertible, Comparable, Hashable, Codable
155155
return false
156156
}
157157

158+
public func hash(into hasher: inout Hasher) {
159+
hasher.combine(start)
160+
}
161+
158162
public var hashValue: Int {
159163
var buf: (UInt, UInt) = (UInt(start.timeIntervalSinceReferenceDate), UInt(end.timeIntervalSinceReferenceDate))
160164
return withUnsafeMutablePointer(to: &buf) {

stdlib/public/Darwin/Foundation/Decimal.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ extension Decimal : Hashable, Comparable {
177177
return _isNegative != 0 ? -d : d
178178
}
179179

180+
public func hash(into hasher: inout Hasher) {
181+
hasher.combine(doubleValue)
182+
}
183+
180184
public var hashValue: Int {
181185
return Int(bitPattern: __CFHashDouble(doubleValue))
182186
}

stdlib/public/Darwin/Foundation/IndexSet.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
136136
public init() {
137137
_handle = _MutablePairHandle(NSIndexSet(), copying: false)
138138
}
139+
140+
public func hash(into hasher: inout Hasher) {
141+
hasher.combine(_handle.map { $0.hash })
142+
}
139143

140144
public var hashValue: Int {
141145
return _handle.map { $0.hash }

stdlib/public/Darwin/Foundation/JSONEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ open class JSONDecoder {
11281128
let leadingUnderscoreRange = stringKey.startIndex..<firstNonUnderscore
11291129
let trailingUnderscoreRange = stringKey.index(after: lastNonUnderscore)..<stringKey.endIndex
11301130

1131-
var components = stringKey[keyRange].split(separator: "_")
1131+
let components = stringKey[keyRange].split(separator: "_")
11321132
let joinedString : String
11331133
if components.count == 1 {
11341134
// No underscores in key, leave the word as is - maybe already camel cased

stdlib/public/Darwin/Foundation/Locale.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ public struct Locale : Hashable, Equatable, ReferenceConvertible {
404404

405405
// MARK: -
406406
//
407+
408+
public func hash(into hasher: inout Hasher) {
409+
hasher.combine(_wrapped)
410+
hasher.combine(_autoupdating)
411+
}
407412

408413
public var hashValue : Int {
409414
if _autoupdating {

stdlib/public/Darwin/Foundation/Measurement.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ public struct Measurement<UnitType : Unit> : ReferenceConvertible, Comparable, E
3636
self.unit = unit
3737
}
3838

39+
public func hash(into hasher: inout Hasher) {
40+
hasher.combine(value)
41+
}
42+
3943
public var hashValue: Int {
4044
return Int(bitPattern: __CFHashDouble(value))
4145
}

stdlib/public/Darwin/Foundation/Notification.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ public struct Notification : ReferenceConvertible, Equatable, Hashable {
3939
self.userInfo = userInfo
4040
}
4141

42+
public func hash(into hasher: inout Hasher) {
43+
hasher.combine(name)
44+
}
45+
4246
public var hashValue: Int {
4347
return name.rawValue.hash
4448
}

stdlib/public/Darwin/Foundation/PersonNameComponents.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public struct PersonNameComponents : ReferenceConvertible, Hashable, Equatable,
7070
get { return _handle.map { $0.phoneticRepresentation } }
7171
set { _applyMutation { $0.phoneticRepresentation = newValue } }
7272
}
73+
74+
public func hash(into hasher: inout Hasher) {
75+
hasher.combine(_handle.map { $0 })
76+
}
7377

7478
public var hashValue : Int {
7579
return _handle.map { $0.hash }

stdlib/public/Darwin/Foundation/TimeZone.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public struct TimeZone : Hashable, Equatable, ReferenceConvertible {
195195
}
196196

197197
// MARK: -
198+
199+
public func hash(into hasher: inout Hasher) {
200+
hasher.combine(_wrapped)
201+
}
198202

199203
public var hashValue : Int {
200204
if _autoupdating {

stdlib/public/Darwin/Foundation/URL.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,10 @@ public struct URL : ReferenceConvertible, Equatable {
621621
public init(fileURLWithFileSystemRepresentation path: UnsafePointer<Int8>, isDirectory: Bool, relativeTo baseURL: __shared URL?) {
622622
_url = URL._converted(from: NSURL(fileURLWithFileSystemRepresentation: path, isDirectory: isDirectory, relativeTo: baseURL))
623623
}
624+
625+
public func hash(into hasher: inout Hasher) {
626+
hasher.combine(_url.hash)
627+
}
624628

625629
public var hashValue: Int {
626630
return _url.hash

stdlib/public/Darwin/Foundation/URLComponents.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ public struct URLComponents : ReferenceConvertible, Hashable, Equatable, _Mutabl
291291
get { return _handle.map { $0.percentEncodedQueryItems } }
292292
set { _applyMutation { $0.percentEncodedQueryItems = newValue } }
293293
}
294+
295+
public func hash(into hasher: inout Hasher) {
296+
hasher.combine(_handle.map { $0.hash })
297+
}
294298

295299
public var hashValue: Int {
296300
return _handle.map { $0.hash }
@@ -403,6 +407,10 @@ public struct URLQueryItem : ReferenceConvertible, Hashable, Equatable {
403407
get { return _queryItem.value }
404408
set { _queryItem = NSURLQueryItem(name: name, value: newValue) }
405409
}
410+
411+
public func hash(into hasher: inout Hasher) {
412+
hasher.combine(_queryItem.hash)
413+
}
406414

407415
public var hashValue: Int { return _queryItem.hash }
408416

stdlib/public/Darwin/Foundation/URLRequest.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ public struct URLRequest : ReferenceConvertible, Equatable, Hashable {
228228
_applyMutation { $0.httpShouldUsePipelining = newValue }
229229
}
230230
}
231+
232+
public func hash(into hasher: inout Hasher) {
233+
hasher.combine(_handle.map { $0.hashValue })
234+
}
231235

232236
public var hashValue: Int {
233237
return _handle.map { $0.hashValue }

0 commit comments

Comments
 (0)