From b0d2daea6d466790f81ed10f07519ee2ae45cabb Mon Sep 17 00:00:00 2001 From: Daniel Duan Date: Sun, 31 Jul 2016 12:16:47 -0700 Subject: [PATCH] update for SE-0110 --- Foundation/NSArray.swift | 2 +- Foundation/NSDictionary.swift | 4 ++-- Foundation/NSError.swift | 12 ++++++------ Foundation/NSIndexSet.swift | 4 ++-- Foundation/NSJSONSerialization.swift | 4 ++-- Foundation/NSXMLNode.swift | 4 ++-- Foundation/NSXMLParser.swift | 6 +++--- TestFoundation/TestNSCompoundPredicate.swift | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Foundation/NSArray.swift b/Foundation/NSArray.swift index 6aa046186e..e16c3ddce4 100644 --- a/Foundation/NSArray.swift +++ b/Foundation/NSArray.swift @@ -382,7 +382,7 @@ public class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NS let hash = item.hash buffer.advanced(by: idx).pointee = Int32(hash).littleEndian } - return Data(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer.self), count: count * MemoryLayout.size, deallocator: .custom({ _ in + return Data(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer.self), count: count * MemoryLayout.size, deallocator: .custom({ _, _ in buffer.deallocate(capacity: size) buffer.deinitialize(count: size) })) diff --git a/Foundation/NSDictionary.swift b/Foundation/NSDictionary.swift index 9461715a89..211b9a65e3 100644 --- a/Foundation/NSDictionary.swift +++ b/Foundation/NSDictionary.swift @@ -18,8 +18,8 @@ extension Dictionary : _ObjectTypeBridgeable { var idx = 0 self.forEach { - let key = _NSObjectRepresentableBridge($0.0) - let value = _NSObjectRepresentableBridge($0.1) + let key = _NSObjectRepresentableBridge($0) + let value = _NSObjectRepresentableBridge($1) keyBuffer.advanced(by: idx).initialize(to: key) valueBuffer.advanced(by: idx).initialize(to: value) idx += 1 diff --git a/Foundation/NSError.swift b/Foundation/NSError.swift index 056d95afca..589778a481 100644 --- a/Foundation/NSError.swift +++ b/Foundation/NSError.swift @@ -59,9 +59,9 @@ public class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding { if let info = aDecoder.decodeObjectOfClasses([NSSet.self, NSDictionary.self, NSArray.self, NSString.self, NSNumber.self, NSData.self, NSURL.self], forKey: "NSUserInfo") as? NSDictionary { var filteredUserInfo = [String : Any]() // user info must be filtered so that the keys are all strings - info.enumerateKeysAndObjects([]) { - if let key = $0.0 as? NSString { - filteredUserInfo[key._swiftObject] = $0.1 + info.enumerateKeysAndObjects([]) { key, object, _ in + if let key = key as? NSString { + filteredUserInfo[key._swiftObject] = object } } _userInfo = filteredUserInfo @@ -74,9 +74,9 @@ public class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding { if let info = aDecoder.decodeObject() as? NSDictionary { var filteredUserInfo = [String : Any]() // user info must be filtered so that the keys are all strings - info.enumerateKeysAndObjects([]) { - if let key = $0.0 as? NSString { - filteredUserInfo[key._swiftObject] = $0.1 + info.enumerateKeysAndObjects([]) { key, object, _ in + if let key = key as? NSString { + filteredUserInfo[key._swiftObject] = object } } _userInfo = filteredUserInfo diff --git a/Foundation/NSIndexSet.swift b/Foundation/NSIndexSet.swift index ec4c52ed25..104d869b74 100644 --- a/Foundation/NSIndexSet.swift +++ b/Foundation/NSIndexSet.swift @@ -86,8 +86,8 @@ public class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding { public func mutableCopy(with zone: NSZone? = nil) -> AnyObject { let set = NSMutableIndexSet() - enumerateRanges([]) { - set.add(in: $0.0) + enumerateRanges([]) { i, _ in + set.add(in: i) } return set } diff --git a/Foundation/NSJSONSerialization.swift b/Foundation/NSJSONSerialization.swift index 32690efd9a..462f5dd27f 100644 --- a/Foundation/NSJSONSerialization.swift +++ b/Foundation/NSJSONSerialization.swift @@ -667,7 +667,7 @@ private struct JSONReader { if source.encoding == String.Encoding.utf8 { - return parseTypedNumber(source.buffer.baseAddress!.advanced(by: input), count: source.buffer.count - input).map { return ($0.0, input + $0.1) } + return parseTypedNumber(source.buffer.baseAddress!.advanced(by: input), count: source.buffer.count - input).map { return ($0, input + $1) } } else { var numberCharacters = [UInt8]() @@ -681,7 +681,7 @@ private struct JSONReader { return numberCharacters.withUnsafeBufferPointer { parseTypedNumber($0.baseAddress!, count: $0.count) - }.map { return ($0.0, index) } + }.map { any, _ in return (any, index) } } } diff --git a/Foundation/NSXMLNode.swift b/Foundation/NSXMLNode.swift index c28bbc9224..1b3539d61b 100644 --- a/Foundation/NSXMLNode.swift +++ b/Foundation/NSXMLNode.swift @@ -578,8 +578,8 @@ public class XMLNode: NSObject, NSCopying { if let parentNode = _CFXMLNodeGetParent(parent!) { let grandparent = XMLNode._objectNodeForNode(parentNode) let possibleParentNodes = grandparent.filter { $0.name == self.parent?.name } - let count = possibleParentNodes.reduce(0) { - return $0.0 + 1 + let count = possibleParentNodes.reduce(0) { n, _ in + return n + 1 } if count <= 1 { diff --git a/Foundation/NSXMLParser.swift b/Foundation/NSXMLParser.swift index 0f094d8caa..db9d318c4e 100644 --- a/Foundation/NSXMLParser.swift +++ b/Foundation/NSXMLParser.swift @@ -640,7 +640,7 @@ public class XMLParser : NSObject { _namespaces.append(ns) if let del = self.delegate { ns.forEach { - del.parser(self, didStartMappingPrefix: $0.0, toURI: $0.1) + del.parser(self, didStartMappingPrefix: $0, toURI: $1) } } } @@ -648,8 +648,8 @@ public class XMLParser : NSObject { internal func _popNamespaces() { let ns = _namespaces.removeLast() if let del = self.delegate { - ns.forEach { - del.parser(self, didEndMappingPrefix: $0.0) + ns.forEach { prefix, _ in + del.parser(self, didEndMappingPrefix: prefix) } } } diff --git a/TestFoundation/TestNSCompoundPredicate.swift b/TestFoundation/TestNSCompoundPredicate.swift index 7b2985ece0..8bb79757c5 100644 --- a/TestFoundation/TestNSCompoundPredicate.swift +++ b/TestFoundation/TestNSCompoundPredicate.swift @@ -92,7 +92,7 @@ class TestNSCompoundPredicate: XCTestCase { var shortCircuited = true let bOK = Predicate(value: false) - let bDontEval = Predicate(block: { _ in + let bDontEval = Predicate(block: { _, _ in shortCircuited = false return true }) @@ -106,7 +106,7 @@ class TestNSCompoundPredicate: XCTestCase { var shortCircuited = true let bOK = Predicate(value: true) - let bDontEval = Predicate(block: { _ in + let bDontEval = Predicate(block: { _, _ in shortCircuited = false return true })