Skip to content

Silence warnings from SE-0099 #479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS
}

public override func isEqual(_ object: AnyObject?) -> Bool {
guard let otherObject = object where otherObject is NSArray else {
guard let otherObject = object, otherObject is NSArray else {
return false
}
let otherArray = otherObject as! NSArray
Expand Down
8 changes: 4 additions & 4 deletions Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,15 @@ public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
while i < self.length {
if i > 0 && i % 4 == 0 {
// if there's a limit, and we're at the barrier where we'd add the ellipses, don't add a space.
if let limit = limit where self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
if let limit = limit, self.length > limit && i == self.length - (limit / 2) { /* do nothing */ }
else { s += " " }
}
let byte = buffer[i]
var byteStr = String(byte, radix: 16, uppercase: false)
if byte <= 0xf { byteStr = "0\(byteStr)" }
s += byteStr
// if we've hit the midpoint of the limit, skip to the last (limit / 2) bytes.
if let limit = limit where self.length > limit && i == (limit / 2) - 1 {
if let limit = limit, self.length > limit && i == (limit / 2) - 1 {
s += " ... "
i = self.length - (limit / 2)
} else {
Expand Down Expand Up @@ -515,7 +515,7 @@ extension NSData {
///
/// 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).
public func write(to url: URL, options writeOptionsMask: WritingOptions = []) throws {
guard let path = url.path where url.isFileURL == true else {
guard let path = url.path, url.isFileURL == true else {
let userInfo = [NSLocalizedDescriptionKey : "The folder at “\(url)” does not exist or is not a file URL.", // NSLocalizedString() not yet available
NSURLErrorKey : url.absoluteString ?? ""] as Dictionary<String, Any>
throw NSError(domain: NSCocoaErrorDomain, code: 4, userInfo: userInfo)
Expand Down Expand Up @@ -846,7 +846,7 @@ extension NSData {
let appendByteToResult : (UInt8) -> () = {
result.append($0)
currentLineCount += 1
if let options = lineOptions where currentLineCount == options.lineLength {
if let options = lineOptions, currentLineCount == options.lineLength {
result.append(contentsOf: options.separator)
currentLineCount = 0
}
Expand Down
12 changes: 4 additions & 8 deletions Foundation/NSHTTPCookie.swift
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ public class HTTPCookie : NSObject {
_domain = canonicalDomain

if let
secureString = properties[NSHTTPCookieSecure] as? String
where secureString.characters.count > 0
secureString = properties[NSHTTPCookieSecure] as? String, secureString.characters.count > 0
{
_secure = true
} else {
Expand All @@ -236,17 +235,15 @@ public class HTTPCookie : NSObject {

let version: Int
if let
versionString = properties[NSHTTPCookieVersion] as? String
where versionString == "1"
versionString = properties[NSHTTPCookieVersion] as? String, versionString == "1"
{
version = 1
} else {
version = 0
}
_version = version

if let portString = properties[NSHTTPCookiePort] as? String
where _version == 1 {
if let portString = properties[NSHTTPCookiePort] as? String, _version == 1 {
_portList = portString.characters
.split(separator: ",")
.flatMap { Int(String($0)) }
Expand All @@ -271,8 +268,7 @@ public class HTTPCookie : NSObject {
}
} else if
let maximumAge = properties[NSHTTPCookieMaximumAge] as? String,
let secondsFromNow = Int(maximumAge)
where _version == 1 {
let secondsFromNow = Int(maximumAge), _version == 1 {
_expiresDate = Date(timeIntervalSinceNow: Double(secondsFromNow))
} else {
_expiresDate = nil
Expand Down
8 changes: 4 additions & 4 deletions Foundation/NSJSONSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ private struct JSONReader {

func consumeWhitespace(_ input: Index) -> Index? {
var index = input
while let (char, nextIndex) = source.takeASCII(index) where JSONReader.whitespaceASCII.contains(char) {
while let (char, nextIndex) = source.takeASCII(index), JSONReader.whitespaceASCII.contains(char) {
index = nextIndex
}
return index
Expand Down Expand Up @@ -521,7 +521,7 @@ private struct JSONReader {

func takeMatching(_ match: (UInt8) -> Bool) -> ([Character], Index) -> ([Character], Index)? {
return { input, index in
guard let (byte, index) = self.source.takeASCII(index) where match(byte) else {
guard let (byte, index) = self.source.takeASCII(index), match(byte) else {
return nil
}
return (input + [Character(UnicodeScalar(byte))], index)
Expand Down Expand Up @@ -601,7 +601,7 @@ private struct JSONReader {
return (String(UnicodeScalar(codeUnit)), index)
}

guard let (trailCodeUnit, finalIndex) = try consumeASCIISequence("\\u", input: index).flatMap(parseCodeUnit) where UTF16.isTrailSurrogate(trailCodeUnit) else {
guard let (trailCodeUnit, finalIndex) = try consumeASCIISequence("\\u", input: index).flatMap(parseCodeUnit) , UTF16.isTrailSurrogate(trailCodeUnit) else {
throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.PropertyListReadCorruptError.rawValue, userInfo: [
"NSDebugDescription" : "Unable to convert unicode escape sequence (no low-surrogate code point) to UTF8-encoded character at position \(source.distanceFromStart(input))"
])
Expand Down Expand Up @@ -670,7 +670,7 @@ private struct JSONReader {
else {
var numberCharacters = [UInt8]()
var index = input
while let (ascii, nextIndex) = source.takeASCII(index) where JSONReader.numberCodePoints.contains(ascii) {
while let (ascii, nextIndex) = source.takeASCII(index), JSONReader.numberCodePoints.contains(ascii) {
numberCharacters.append(ascii)
index = nextIndex
}
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSOrderedSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ extension NSOrderedSet {
public convenience init(array set: [AnyObject], range: NSRange, copyItems flag: Bool) {
var objects = set

if let range = range.toRange() where range.count != set.count || flag {
if let range = range.toRange(), range.count != set.count || flag {
objects = [AnyObject]()
for index in range.indices {
let object = set[index] as! NSObject
Expand Down
4 changes: 2 additions & 2 deletions Foundation/NSSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
NSRequiresConcreteImplementation()
}

guard let obj = object as? NSObject where _storage.contains(obj) else {
guard let obj = object as? NSObject, _storage.contains(obj) else {
return nil
}

Expand Down Expand Up @@ -189,7 +189,7 @@ public class NSSet : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
}

public override func isEqual(_ object: AnyObject?) -> Bool {
guard let otherObject = object where otherObject is NSSet else {
guard let otherObject = object, otherObject is NSSet else {
return false
}
let otherSet = otherObject as! NSSet
Expand Down