Skip to content

Commit 37a4fba

Browse files
committed
Silence warnings from SE-0099
1 parent 2acafc7 commit 37a4fba

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
@@ -198,15 +198,15 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
198198
while i < self.length {
199199
if i > 0 && i % 4 == 0 {
200200
// if there's a limit, and we're at the barrier where we'd add the ellipses, don't add a space.
201-
if let limit = limit where self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
201+
if let limit = limit, self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
202202
else { s += " " }
203203
}
204204
let byte = buffer[i]
205205
var byteStr = String(byte, radix: 16, uppercase: false)
206206
if byte <= 0xf { byteStr = "0\(byteStr)" }
207207
s += byteStr
208208
// if we've hit the midpoint of the limit, skip to the last (limit / 2) bytes.
209-
if let limit = limit where self.length > limit && i == (limit / 2) - 1 {
209+
if let limit = limit, self.length > limit && i == (limit / 2) - 1 {
210210
s += " ... "
211211
i = self.length - (limit / 2)
212212
} else {
@@ -515,7 +515,7 @@ extension NSData {
515515
///
516516
/// 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).
517517
public func write(to url: URL, options writeOptionsMask: WritingOptions = []) throws {
518-
guard let path = url.path where url.isFileURL == true else {
518+
guard let path = url.path, url.isFileURL == true else {
519519
let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL.", // NSLocalizedString() not yet available
520520
NSURLErrorKey : url.absoluteString ?? ""] as Dictionary<String, Any>
521521
throw NSError(domain: NSCocoaErrorDomain, code: 4, userInfo: userInfo)
@@ -846,7 +846,7 @@ extension NSData {
846846
let appendByteToResult : (UInt8) -> () = {
847847
result.append($0)
848848
currentLineCount += 1
849-
if let options = lineOptions where currentLineCount == options.lineLength {
849+
if let options = lineOptions, currentLineCount == options.lineLength {
850850
result.append(contentsOf: options.separator)
851851
currentLineCount = 0
852852
}

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
@@ -483,7 +483,7 @@ private struct JSONReader {
483483

484484
func consumeWhitespace(_ input: Index) -> Index? {
485485
var index = input
486-
while let (char, nextIndex) = source.takeASCII(index) where JSONReader.whitespaceASCII.contains(char) {
486+
while let (char, nextIndex) = source.takeASCII(index), JSONReader.whitespaceASCII.contains(char) {
487487
index = nextIndex
488488
}
489489
return index
@@ -521,7 +521,7 @@ private struct JSONReader {
521521

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

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

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)