Skip to content

Commit 7c28dca

Browse files
authored
Revert "Updates for SE-0110 Part I" (swiftlang#500)
The changes to higher-order functions are not correct.
1 parent 76542be commit 7c28dca

8 files changed

+20
-20
lines changed

Foundation/NSArray.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
382382
let hash = item.hash
383383
buffer.advanced(by: idx).pointee = Int32(hash).littleEndian
384384
}
385-
return Data(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer<UInt8>.self), count: count * MemoryLayout<Int>.size, deallocator: .custom({ _, _ in
385+
return Data(bytesNoCopy: unsafeBitCast(buffer, to: UnsafeMutablePointer<UInt8>.self), count: count * MemoryLayout<Int>.size, deallocator: .custom({ _ in
386386
buffer.deallocate(capacity: size)
387387
buffer.deinitialize(count: size)
388388
}))

Foundation/NSDictionary.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ extension Dictionary : _ObjectTypeBridgeable {
1818
var idx = 0
1919

2020
self.forEach {
21-
let key = _NSObjectRepresentableBridge($0)
22-
let value = _NSObjectRepresentableBridge($1)
21+
let key = _NSObjectRepresentableBridge($0.0)
22+
let value = _NSObjectRepresentableBridge($0.1)
2323
keyBuffer.advanced(by: idx).initialize(to: key)
2424
valueBuffer.advanced(by: idx).initialize(to: value)
2525
idx += 1

Foundation/NSError.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
5959
if let info = aDecoder.decodeObjectOfClasses([NSSet.self, NSDictionary.self, NSArray.self, NSString.self, NSNumber.self, NSData.self, NSURL.self], forKey: "NSUserInfo") as? NSDictionary {
6060
var filteredUserInfo = [String : Any]()
6161
// user info must be filtered so that the keys are all strings
62-
info.enumerateKeysAndObjects([]) { key, object, _ in
63-
if let key = key as? NSString {
64-
filteredUserInfo[key._swiftObject] = object
62+
info.enumerateKeysAndObjects([]) {
63+
if let key = $0.0 as? NSString {
64+
filteredUserInfo[key._swiftObject] = $0.1
6565
}
6666
}
6767
_userInfo = filteredUserInfo
@@ -74,9 +74,9 @@ open class NSError : NSObject, NSCopying, NSSecureCoding, NSCoding {
7474
if let info = aDecoder.decodeObject() as? NSDictionary {
7575
var filteredUserInfo = [String : Any]()
7676
// user info must be filtered so that the keys are all strings
77-
info.enumerateKeysAndObjects([]) { key, object, _ in
78-
if let key = key as? NSString {
79-
filteredUserInfo[key._swiftObject] = object
77+
info.enumerateKeysAndObjects([]) {
78+
if let key = $0.0 as? NSString {
79+
filteredUserInfo[key._swiftObject] = $0.1
8080
}
8181
}
8282
_userInfo = filteredUserInfo

Foundation/NSIndexSet.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ open class NSIndexSet: NSObject, NSCopying, NSMutableCopying, NSSecureCoding {
8686

8787
open func mutableCopy(with zone: NSZone? = nil) -> AnyObject {
8888
let set = NSMutableIndexSet()
89-
enumerateRanges([]) { i, _ in
90-
set.add(in: i)
89+
enumerateRanges([]) {
90+
set.add(in: $0.0)
9191
}
9292
return set
9393
}

Foundation/NSJSONSerialization.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ private struct JSONReader {
667667

668668
if source.encoding == String.Encoding.utf8 {
669669

670-
return parseTypedNumber(source.buffer.baseAddress!.advanced(by: input), count: source.buffer.count - input).map { return ($0, input + $1) }
670+
return parseTypedNumber(source.buffer.baseAddress!.advanced(by: input), count: source.buffer.count - input).map { return ($0.0, input + $0.1) }
671671
}
672672
else {
673673
var numberCharacters = [UInt8]()
@@ -681,7 +681,7 @@ private struct JSONReader {
681681

682682
return numberCharacters.withUnsafeBufferPointer {
683683
parseTypedNumber($0.baseAddress!, count: $0.count)
684-
}.map { any, _ in return (any, index) }
684+
}.map { return ($0.0, index) }
685685
}
686686
}
687687

Foundation/NSXMLNode.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ open class XMLNode: NSObject, NSCopying {
578578
if let parentNode = _CFXMLNodeGetParent(parent!) {
579579
let grandparent = XMLNode._objectNodeForNode(parentNode)
580580
let possibleParentNodes = grandparent.filter { $0.name == self.parent?.name }
581-
let count = possibleParentNodes.reduce(0) { n, _ in
582-
return n + 1
581+
let count = possibleParentNodes.reduce(0) {
582+
return $0.0 + 1
583583
}
584584

585585
if count <= 1 {

Foundation/NSXMLParser.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,16 @@ open class XMLParser : NSObject {
640640
_namespaces.append(ns)
641641
if let del = self.delegate {
642642
ns.forEach {
643-
del.parser(self, didStartMappingPrefix: $0, toURI: $1)
643+
del.parser(self, didStartMappingPrefix: $0.0, toURI: $0.1)
644644
}
645645
}
646646
}
647647

648648
internal func _popNamespaces() {
649649
let ns = _namespaces.removeLast()
650650
if let del = self.delegate {
651-
ns.forEach { prefix, _ in
652-
del.parser(self, didEndMappingPrefix: prefix)
651+
ns.forEach {
652+
del.parser(self, didEndMappingPrefix: $0.0)
653653
}
654654
}
655655
}

TestFoundation/TestNSCompoundPredicate.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TestNSCompoundPredicate: XCTestCase {
9292
var shortCircuited = true
9393

9494
let bOK = Predicate(value: false)
95-
let bDontEval = Predicate(block: { _, _ in
95+
let bDontEval = Predicate(block: { _ in
9696
shortCircuited = false
9797
return true
9898
})
@@ -106,7 +106,7 @@ class TestNSCompoundPredicate: XCTestCase {
106106
var shortCircuited = true
107107

108108
let bOK = Predicate(value: true)
109-
let bDontEval = Predicate(block: { _, _ in
109+
let bDontEval = Predicate(block: { _ in
110110
shortCircuited = false
111111
return true
112112
})

0 commit comments

Comments
 (0)