Skip to content

Commit 3348b82

Browse files
authored
Merge pull request #479 from milseman/silence_warnings
Silence warnings from SE-0099
2 parents 87dc687 + 37a4fba commit 3348b82

File tree

6 files changed

+16
-20
lines changed

6 files changed

+16
-20
lines changed

Foundation/NSArray.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
166166
}
167167

168168
public override func isEqual(_ object: AnyObject?) -> Bool {
169-
guard let otherObject = object where otherObject is NSArray else {
169+
guard let otherObject = object, otherObject is NSArray else {
170170
return false
171171
}
172172
let otherArray = otherObject as! NSArray

Foundation/NSData.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
200200
while i < self.length {
201201
if i > 0 && i % 4 == 0 {
202202
// if there's a limit, and we're at the barrier where we'd add the ellipses, don't add a space.
203-
if let limit = limit where self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
203+
if let limit = limit, self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
204204
else { s += " " }
205205
}
206206
let byte = bytes.load(fromByteOffset: i, as: UInt8.self)
207207
var byteStr = String(byte, radix: 16, uppercase: false)
208208
if byte <= 0xf { byteStr = "0\(byteStr)" }
209209
s += byteStr
210210
// if we've hit the midpoint of the limit, skip to the last (limit / 2) bytes.
211-
if let limit = limit where self.length > limit && i == (limit / 2) - 1 {
211+
if let limit = limit, self.length > limit && i == (limit / 2) - 1 {
212212
s += " ... "
213213
i = self.length - (limit / 2)
214214
} else {
@@ -519,7 +519,7 @@ extension NSData {
519519
///
520520
/// This method is invoked in a `try` expression and the caller is responsible for handling any errors in the `catch` clauses of a `do` statement, as described in [Error Handling](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/ErrorHandling.html#//apple_ref/doc/uid/TP40014097-CH42) in [The Swift Programming Language](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/index.html#//apple_ref/doc/uid/TP40014097) and [Error Handling](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/AdoptingCocoaDesignPatterns.html#//apple_ref/doc/uid/TP40014216-CH7-ID10) in [Using Swift with Cocoa and Objective-C](https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/index.html#//apple_ref/doc/uid/TP40014216).
521521
public func write(to url: URL, options writeOptionsMask: WritingOptions = []) throws {
522-
guard let path = url.path where url.isFileURL == true else {
522+
guard let path = url.path, url.isFileURL == true else {
523523
let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL.", // NSLocalizedString() not yet available
524524
NSURLErrorKey : url.absoluteString ?? ""] as Dictionary<String, Any>
525525
throw NSError(domain: NSCocoaErrorDomain, code: 4, userInfo: userInfo)
@@ -852,7 +852,7 @@ extension NSData {
852852
let appendByteToResult : (UInt8) -> () = {
853853
result.append($0)
854854
currentLineCount += 1
855-
if let options = lineOptions where currentLineCount == options.lineLength {
855+
if let options = lineOptions, currentLineCount == options.lineLength {
856856
result.append(contentsOf: options.separator)
857857
currentLineCount = 0
858858
}

Foundation/NSHTTPCookie.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ public class HTTPCookie : NSObject {
226226
_domain = canonicalDomain
227227

228228
if let
229-
secureString = properties[NSHTTPCookieSecure] as? String
230-
where secureString.characters.count > 0
229+
secureString = properties[NSHTTPCookieSecure] as? String, secureString.characters.count > 0
231230
{
232231
_secure = true
233232
} else {
@@ -236,17 +235,15 @@ public class HTTPCookie : NSObject {
236235

237236
let version: Int
238237
if let
239-
versionString = properties[NSHTTPCookieVersion] as? String
240-
where versionString == "1"
238+
versionString = properties[NSHTTPCookieVersion] as? String, versionString == "1"
241239
{
242240
version = 1
243241
} else {
244242
version = 0
245243
}
246244
_version = version
247245

248-
if let portString = properties[NSHTTPCookiePort] as? String
249-
where _version == 1 {
246+
if let portString = properties[NSHTTPCookiePort] as? String, _version == 1 {
250247
_portList = portString.characters
251248
.split(separator: ",")
252249
.flatMap { Int(String($0)) }
@@ -271,8 +268,7 @@ public class HTTPCookie : NSObject {
271268
}
272269
} else if
273270
let maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
274-
let secondsFromNow = Int(maximumAge)
275-
where _version == 1 {
271+
let secondsFromNow = Int(maximumAge), _version == 1 {
276272
_expiresDate = Date(timeIntervalSinceNow: Double(secondsFromNow))
277273
} else {
278274
_expiresDate = nil

Foundation/NSJSONSerialization.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ private struct JSONReader {
484484

485485
func consumeWhitespace(_ input: Index) -> Index? {
486486
var index = input
487-
while let (char, nextIndex) = source.takeASCII(index) where JSONReader.whitespaceASCII.contains(char) {
487+
while let (char, nextIndex) = source.takeASCII(index), JSONReader.whitespaceASCII.contains(char) {
488488
index = nextIndex
489489
}
490490
return index
@@ -522,7 +522,7 @@ private struct JSONReader {
522522

523523
func takeMatching(_ match: (UInt8) -> Bool) -> ([Character], Index) -> ([Character], Index)? {
524524
return { input, index in
525-
guard let (byte, index) = self.source.takeASCII(index) where match(byte) else {
525+
guard let (byte, index) = self.source.takeASCII(index), match(byte) else {
526526
return nil
527527
}
528528
return (input + [Character(UnicodeScalar(byte))], index)
@@ -602,7 +602,7 @@ private struct JSONReader {
602602
return (String(UnicodeScalar(codeUnit)), index)
603603
}
604604

605-
guard let (trailCodeUnit, finalIndex) = try consumeASCIISequence("\\u", input: index).flatMap(parseCodeUnit) where UTF16.isTrailSurrogate(trailCodeUnit) else {
605+
guard let (trailCodeUnit, finalIndex) = try consumeASCIISequence("\\u", input: index).flatMap(parseCodeUnit) , UTF16.isTrailSurrogate(trailCodeUnit) else {
606606
throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.PropertyListReadCorruptError.rawValue, userInfo: [
607607
"NSDebugDescription" : "Unable to convert unicode escape sequence (no low-surrogate code point) to UTF8-encoded character at position \(source.distanceFromStart(input))"
608608
])
@@ -671,7 +671,7 @@ private struct JSONReader {
671671
else {
672672
var numberCharacters = [UInt8]()
673673
var index = input
674-
while let (ascii, nextIndex) = source.takeASCII(index) where JSONReader.numberCodePoints.contains(ascii) {
674+
while let (ascii, nextIndex) = source.takeASCII(index), JSONReader.numberCodePoints.contains(ascii) {
675675
numberCharacters.append(ascii)
676676
index = nextIndex
677677
}

Foundation/NSOrderedSet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ extension NSOrderedSet {
301301
public convenience init(array set: [AnyObject], range: NSRange, copyItems flag: Bool) {
302302
var objects = set
303303

304-
if let range = range.toRange() where range.count != set.count || flag {
304+
if let range = range.toRange(), range.count != set.count || flag {
305305
objects = [AnyObject]()
306306
for index in range.indices {
307307
let object = set[index] as! NSObject

Foundation/NSSet.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
8686
NSRequiresConcreteImplementation()
8787
}
8888

89-
guard let obj = object as? NSObject where _storage.contains(obj) else {
89+
guard let obj = object as? NSObject, _storage.contains(obj) else {
9090
return nil
9191
}
9292

@@ -189,7 +189,7 @@ public class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
189189
}
190190

191191
public override func isEqual(_ object: AnyObject?) -> Bool {
192-
guard let otherObject = object where otherObject is NSSet else {
192+
guard let otherObject = object, otherObject is NSSet else {
193193
return false
194194
}
195195
let otherSet = otherObject as! NSSet

0 commit comments

Comments
 (0)