Skip to content

Commit 2000be1

Browse files
committed
Fix Any? -> Any build warnings
1 parent a2904a2 commit 2000be1

File tree

4 files changed

+36
-17
lines changed

4 files changed

+36
-17
lines changed

Foundation/TimeZone.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ extension TimeZone : CustomStringConvertible, CustomDebugStringConvertible, Cust
236236
var c: [(label: String?, value: Any)] = []
237237
c.append((label: "identifier", value: identifier))
238238
c.append((label: "kind", value: _kindDescription))
239-
c.append((label: "abbreviation", value: abbreviation()))
239+
c.append((label: "abbreviation", value: abbreviation() as Any))
240240
c.append((label: "secondsFromGMT", value: secondsFromGMT()))
241241
c.append((label: "isDaylightSavingTime", value: isDaylightSavingTime()))
242242
return Mirror(self, children: c, displayStyle: Mirror.DisplayStyle.struct)

Foundation/URLComponents.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,11 +368,11 @@ extension URLQueryItem : CustomStringConvertible, CustomDebugStringConvertible,
368368
public var debugDescription: String {
369369
return self.description
370370
}
371-
371+
372372
public var customMirror: Mirror {
373373
var c: [(label: String?, value: Any)] = []
374374
c.append((label: "name", value: name))
375-
c.append((label: "value", value: value))
375+
c.append((label: "value", value: value as Any))
376376
return Mirror(self, children: c, displayStyle: Mirror.DisplayStyle.struct)
377377
}
378378
}

Foundation/URLRequest.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,23 +238,23 @@ extension URLRequest : CustomStringConvertible, CustomDebugStringConvertible, Cu
238238
return "url: nil"
239239
}
240240
}
241-
241+
242242
public var debugDescription: String {
243243
return self.description
244244
}
245-
245+
246246
public var customMirror: Mirror {
247247
var c: [(label: String?, value: Any)] = []
248-
c.append((label: "url", value: url))
248+
c.append((label: "url", value: url as Any))
249249
c.append((label: "cachePolicy", value: cachePolicy.rawValue))
250250
c.append((label: "timeoutInterval", value: timeoutInterval))
251-
c.append((label: "mainDocumentURL", value: mainDocumentURL))
251+
c.append((label: "mainDocumentURL", value: mainDocumentURL as Any))
252252
c.append((label: "networkServiceType", value: networkServiceType))
253253
c.append((label: "allowsCellularAccess", value: allowsCellularAccess))
254-
c.append((label: "httpMethod", value: httpMethod))
255-
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields))
256-
c.append((label: "httpBody", value: httpBody))
257-
c.append((label: "httpBodyStream", value: httpBodyStream))
254+
c.append((label: "httpMethod", value: httpMethod as Any))
255+
c.append((label: "allHTTPHeaderFields", value: allHTTPHeaderFields as Any))
256+
c.append((label: "httpBody", value: httpBody as Any))
257+
c.append((label: "httpBodyStream", value: httpBodyStream as Any))
258258
c.append((label: "httpShouldHandleCookies", value: httpShouldHandleCookies))
259259
c.append((label: "httpShouldUsePipelining", value: httpShouldUsePipelining))
260260
return Mirror(self, children: c, displayStyle: Mirror.DisplayStyle.struct)
@@ -265,21 +265,21 @@ extension URLRequest : _ObjectTypeBridgeable {
265265
public static func _getObjectiveCType() -> Any.Type {
266266
return NSURLRequest.self
267267
}
268-
268+
269269
@_semantics("convertToObjectiveC")
270270
public func _bridgeToObjectiveC() -> NSURLRequest {
271271
return _handle._copiedReference()
272272
}
273-
273+
274274
public static func _forceBridgeFromObjectiveC(_ input: NSURLRequest, result: inout URLRequest?) {
275275
result = URLRequest(_bridged: input)
276276
}
277-
277+
278278
public static func _conditionallyBridgeFromObjectiveC(_ input: NSURLRequest, result: inout URLRequest?) -> Bool {
279279
result = URLRequest(_bridged: input)
280280
return true
281281
}
282-
282+
283283
public static func _unconditionallyBridgeFromObjectiveC(_ source: NSURLRequest?) -> URLRequest {
284284
var result: URLRequest? = nil
285285
_forceBridgeFromObjectiveC(source!, result: &result)

TestFoundation/TestNSTimeZone.swift

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ class TestNSTimeZone: XCTestCase {
3838
("test_localizedName", test_localizedName),
3939
// Also disabled due to https://bugs.swift.org/browse/SR-300
4040
// ("test_systemTimeZoneUsesSystemTime", test_systemTimeZoneUsesSystemTime),
41+
42+
("test_customMirror", test_tz_customMirror),
4143
]
4244
}
4345

@@ -152,7 +154,7 @@ class TestNSTimeZone: XCTestCase {
152154
let tz3 = TimeZone(identifier: "GMT-9999")
153155
XCTAssertNil(tz3)
154156
}
155-
157+
156158
func test_initializingTimeZoneWithAbbreviation() {
157159
// Test invalid timezone abbreviation
158160
var tz = TimeZone(abbreviation: "XXX")
@@ -162,7 +164,7 @@ class TestNSTimeZone: XCTestCase {
162164
let expectedName = "America/Halifax"
163165
XCTAssertEqual(tz?.identifier, expectedName, "expected name \"\(expectedName)\" is not equal to \"\(tz?.identifier)\"")
164166
}
165-
167+
166168
func test_systemTimeZoneUsesSystemTime() {
167169
tzset()
168170
var t = time(nil)
@@ -172,4 +174,21 @@ class TestNSTimeZone: XCTestCase {
172174
let expectedName = String(cString: lt.tm_zone, encoding: String.Encoding.ascii) ?? "Invalid Zone"
173175
XCTAssertEqual(zoneName, expectedName, "expected name \"\(expectedName)\" is not equal to \"\(zoneName)\"")
174176
}
177+
178+
func test_tz_customMirror() {
179+
let tz = TimeZone.current
180+
let mirror = Mirror(reflecting: tz as TimeZone)
181+
var children = [String : Any](minimumCapacity: Int(mirror.children.count))
182+
mirror.children.forEach {
183+
if let label = $0.label {
184+
children[label] = $0.value
185+
}
186+
}
187+
188+
XCTAssertNotNil(children["identifier"])
189+
XCTAssertNotNil(children["kind"])
190+
XCTAssertNotNil(children["abbreviation"])
191+
XCTAssertNotNil(children["secondsFromGMT"])
192+
XCTAssertNotNil(children["isDaylightSavingTime"])
193+
}
175194
}

0 commit comments

Comments
 (0)