Skip to content

Commit 58cf073

Browse files
spevansphausler
authored andcommitted
Remove deprecated @NoEscape which is now the default [SE-0103] (#507)
1 parent 1b1a2eb commit 58cf073

18 files changed

+70
-70
lines changed

Foundation/Boxing.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal final class _MutableHandle<MutableType : NSObject where MutableType : N
2525
}
2626

2727
/// Apply a closure to the reference type.
28-
func map<ReturnType>(_ whatToDo : @noescape (MutableType) throws -> ReturnType) rethrows -> ReturnType {
28+
func map<ReturnType>(_ whatToDo : (MutableType) throws -> ReturnType) rethrows -> ReturnType {
2929
return try whatToDo(_pointer)
3030
}
3131

@@ -45,12 +45,12 @@ internal protocol _MutableBoxing : ReferenceConvertible {
4545
/// Apply a mutating closure to the reference type, regardless if it is mutable or immutable.
4646
///
4747
/// This function performs the correct copy-on-write check for efficient mutation.
48-
mutating func _applyMutation<ReturnType>(_ whatToDo : @noescape (ReferenceType) -> ReturnType) -> ReturnType
48+
mutating func _applyMutation<ReturnType>(_ whatToDo : (ReferenceType) -> ReturnType) -> ReturnType
4949
}
5050

5151
extension _MutableBoxing {
5252
@inline(__always)
53-
mutating func _applyMutation<ReturnType>(_ whatToDo : @noescape(ReferenceType) -> ReturnType) -> ReturnType {
53+
mutating func _applyMutation<ReturnType>(_ whatToDo : (ReferenceType) -> ReturnType) -> ReturnType {
5454
// Only create a new box if we are not uniquely referenced
5555
if !isKnownUniquelyReferenced(&_handle) {
5656
let ref = _handle._pointer
@@ -85,7 +85,7 @@ internal protocol _SwiftNativeFoundationType : class {
8585
extension _SwiftNativeFoundationType {
8686

8787
@inline(__always)
88-
func _mapUnmanaged<ReturnType>(_ whatToDo : @noescape (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
88+
func _mapUnmanaged<ReturnType>(_ whatToDo : (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
8989
defer { _fixLifetime(self) }
9090

9191
switch __wrapped {
@@ -141,7 +141,7 @@ internal protocol _MutablePairBoxing {
141141

142142
extension _MutablePairBoxing {
143143
@inline(__always)
144-
func _mapUnmanaged<ReturnType>(_ whatToDo : @noescape (WrappedSwiftNSType.ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
144+
func _mapUnmanaged<ReturnType>(_ whatToDo : (WrappedSwiftNSType.ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
145145
// We are using Unmananged. Make sure that the owning container class
146146
// 'self' is guaranteed to be alive by extending the lifetime of 'self'
147147
// to the end of the scope of this function.
@@ -166,7 +166,7 @@ extension _MutablePairBoxing {
166166
}
167167

168168
@inline(__always)
169-
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : @noescape (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
169+
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
170170
// We are using Unmananged. Make sure that the owning container class
171171
// 'self' is guaranteed to be alive by extending the lifetime of 'self'
172172
// to the end of the scope of this function.

Foundation/Data.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ internal final class _SwiftNSData : NSData, _SwiftNativeFoundationType {
112112
// }
113113
// }
114114
//
115-
// override func enumerateByteRanges(using block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
115+
// override func enumerateByteRanges(using block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
116116
// return _mapUnmanaged { $0.enumerateBytes(block) }
117117
// }
118118
//
@@ -311,7 +311,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
311311
/// Access the bytes in the data.
312312
///
313313
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
314-
public func withUnsafeBytes<ResultType, ContentType>(_ body: @noescape (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
314+
public func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
315315
let bytes = _getUnsafeBytesPointer()
316316
defer { _fixLifetime(self)}
317317
let contentPtr = bytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
@@ -328,7 +328,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
328328
///
329329
/// This function assumes that you are mutating the contents.
330330
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
331-
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: @noescape (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
331+
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
332332
let mutableBytes = _getUnsafeMutableBytesPointer()
333333
defer { _fixLifetime(self)}
334334
let contentPtr = mutableBytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
@@ -435,7 +435,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
435435
///
436436
/// In some cases, (for example, a `Data` backed by a `dispatch_data_t`, the bytes may be stored discontiguously. In those cases, this function invokes the closure for each contiguous region of bytes.
437437
/// - parameter block: The closure to invoke for each region of data. You may stop the enumeration by setting the `stop` parameter to `true`.
438-
public func enumerateBytes(_ block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
438+
public func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
439439
_mapUnmanaged {
440440
$0.enumerateBytes { (ptr, range, stop) in
441441
var stopv = false

Foundation/IndexSet.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
629629
///
630630
/// - parameter range: A range of integers. For each integer in the range that intersects the integers in the IndexSet, then the `includeInteger predicate will be invoked. Pass `nil` (the default) to use the entire range.
631631
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
632-
public func filteredIndexSet(in range : Range<Element>? = nil, includeInteger: @noescape (Element) throws -> Bool) rethrows -> IndexSet {
632+
public func filteredIndexSet(in range : Range<Element>? = nil, includeInteger: (Element) throws -> Bool) rethrows -> IndexSet {
633633
let r : NSRange = range != nil ? _toNSRange(range!) : NSMakeRange(0, NSNotFound - 1)
634634
return try _handle.map {
635635
var error : Swift.Error? = nil
@@ -667,7 +667,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
667667
// Temporary boxing function, until we can get a native Swift type for NSIndexSet
668668
/// TODO: making this inline causes the compiler to crash horrifically.
669669
// @inline(__always)
670-
mutating func _applyMutation<ReturnType>(_ whatToDo : @noescape (NSMutableIndexSet) throws -> ReturnType) rethrows -> ReturnType {
670+
mutating func _applyMutation<ReturnType>(_ whatToDo : (NSMutableIndexSet) throws -> ReturnType) rethrows -> ReturnType {
671671
switch _handle._pointer {
672672
case .Default(let i):
673673
// We need to become mutable; by creating a new box we also become unique
@@ -845,7 +845,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N
845845

846846
/// Apply a closure to the reference type, regardless if it is mutable or immutable.
847847
@inline(__always)
848-
func map<ReturnType>(_ whatToDo : @noescape (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
848+
func map<ReturnType>(_ whatToDo : (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
849849
switch _pointer {
850850
case .Default(let i):
851851
return try whatToDo(i)

Foundation/NSArray.swift

+15-15
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
390390
}))
391391
}
392392

393-
open func sortedArray(_ comparator: @noescape @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?) -> [AnyObject] {
393+
open func sortedArray(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?) -> [AnyObject] {
394394
return sortedArray([]) { lhs, rhs in
395395
return ComparisonResult(rawValue: comparator(lhs, rhs, context))!
396396
}
397397
}
398398

399-
open func sortedArray(_ comparator: @noescape @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?, hint: Data?) -> [AnyObject] {
399+
open func sortedArray(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?, hint: Data?) -> [AnyObject] {
400400
return sortedArray([]) { lhs, rhs in
401401
return ComparisonResult(rawValue: comparator(lhs, rhs, context))!
402402
}
@@ -431,13 +431,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
431431
return object(at: idx)
432432
}
433433

434-
public func enumerateObjects(_ block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
434+
public func enumerateObjects(_ block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
435435
self.enumerateObjects([], using: block)
436436
}
437-
public func enumerateObjects(_ opts: EnumerationOptions = [], using block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
437+
public func enumerateObjects(_ opts: EnumerationOptions = [], using block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
438438
self.enumerateObjects(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, using: block)
439439
}
440-
public func enumerateObjects(at s: IndexSet, options opts: EnumerationOptions = [], using block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
440+
public func enumerateObjects(at s: IndexSet, options opts: EnumerationOptions = [], using block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
441441
guard !opts.contains(.concurrent) else {
442442
NSUnimplemented()
443443
}
@@ -446,13 +446,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
446446
}
447447
}
448448

449-
open func indexOfObject(passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
449+
open func indexOfObject(passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
450450
return indexOfObject([], passingTest: predicate)
451451
}
452-
open func indexOfObject(_ opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
452+
open func indexOfObject(_ opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
453453
return indexOfObject(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, passingTest: predicate)
454454
}
455-
open func indexOfObject(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
455+
open func indexOfObject(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
456456
var result = NSNotFound
457457
enumerateObjects(at: s, options: opts) { (obj, idx, stop) -> Void in
458458
if predicate(obj, idx, stop) {
@@ -463,13 +463,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
463463
return result
464464
}
465465

466-
open func indexesOfObjects(passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
466+
open func indexesOfObjects(passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
467467
return indexesOfObjects([], passingTest: predicate)
468468
}
469-
open func indexesOfObjects(_ opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
469+
open func indexesOfObjects(_ opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
470470
return indexesOfObjects(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, passingTest: predicate)
471471
}
472-
open func indexesOfObjects(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
472+
open func indexesOfObjects(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
473473
var result = IndexSet()
474474
enumerateObjects(at: s, options: opts) { (obj, idx, stop) in
475475
if predicate(obj, idx, stop) {
@@ -479,7 +479,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
479479
return result
480480
}
481481

482-
internal func sortedArrayFromRange(_ range: NSRange, options: SortOptions, usingComparator cmptr: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
482+
internal func sortedArrayFromRange(_ range: NSRange, options: SortOptions, usingComparator cmptr: (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
483483
// The sort options are not available. We use the Array's sorting algorithm. It is not stable neither concurrent.
484484
guard options.isEmpty else {
485485
NSUnimplemented()
@@ -496,15 +496,15 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
496496
}
497497
}
498498

499-
open func sortedArray(comparator cmptr: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
499+
open func sortedArray(comparator cmptr: (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
500500
return sortedArrayFromRange(NSMakeRange(0, count), options: [], usingComparator: cmptr)
501501
}
502502

503-
open func sortedArray(_ opts: SortOptions = [], usingComparator cmptr: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
503+
open func sortedArray(_ opts: SortOptions = [], usingComparator cmptr: (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
504504
return sortedArrayFromRange(NSMakeRange(0, count), options: opts, usingComparator: cmptr)
505505
}
506506

507-
open func index(of obj: AnyObject, inSortedRange r: NSRange, options opts: NSBinarySearchingOptions = [], usingComparator cmp: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> Int {
507+
open func index(of obj: AnyObject, inSortedRange r: NSRange, options opts: NSBinarySearchingOptions = [], usingComparator cmp: (AnyObject, AnyObject) -> ComparisonResult) -> Int {
508508
let lastIndex = r.location + r.length - 1
509509

510510
// argument validation

Foundation/NSCoder.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ open class NSCoder : NSObject {
250250
}
251251
*/
252252
/// - experimental: This method does not exist in the Darwin Foundation.
253-
open func withDecodedUnsafeBufferPointer<ResultType>(forKey key: String, body: @noescape (UnsafeBufferPointer<UInt8>?) throws -> ResultType) rethrows -> ResultType {
253+
open func withDecodedUnsafeBufferPointer<ResultType>(forKey key: String, body: (UnsafeBufferPointer<UInt8>?) throws -> ResultType) rethrows -> ResultType {
254254
NSRequiresConcreteImplementation()
255255
}
256256

Foundation/NSData.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ extension NSData {
558558
return nil
559559
}
560560

561-
internal func enumerateByteRangesUsingBlockRethrows(_ block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) throws -> Void) throws {
561+
internal func enumerateByteRangesUsingBlockRethrows(_ block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) throws -> Void) throws {
562562
var err : Swift.Error? = nil
563563
self.enumerateBytes() { (buf, range, stop) -> Void in
564564
do {
@@ -572,7 +572,7 @@ extension NSData {
572572
}
573573
}
574574

575-
public func enumerateBytes(_ block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) -> Void) {
575+
public func enumerateBytes(_ block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) -> Void) {
576576
var stop = false
577577
withUnsafeMutablePointer(to: &stop) { stopPointer in
578578
block(bytes, NSMakeRange(0, length), stopPointer)

Foundation/NSDictionary.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -475,11 +475,11 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
475475
open func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> Bool { NSUnimplemented() }
476476
open func write(to url: URL, atomically: Bool) -> Bool { NSUnimplemented() } // the atomically flag is ignored if url of a type that cannot be written atomically.
477477

478-
public func enumerateKeysAndObjects(_ block: @noescape (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Void) {
478+
public func enumerateKeysAndObjects(_ block: (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Void) {
479479
enumerateKeysAndObjects([], using: block)
480480
}
481481

482-
public func enumerateKeysAndObjects(_ opts: EnumerationOptions = [], using block: @noescape (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
482+
public func enumerateKeysAndObjects(_ opts: EnumerationOptions = [], using block: (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
483483
let count = self.count
484484
var keys = [AnyObject]()
485485
var objects = [AnyObject]()
@@ -496,22 +496,22 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
496496
}
497497
}
498498

499-
open func keysSortedByValue(comparator cmptr: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
499+
open func keysSortedByValue(comparator cmptr: (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
500500
return keysSortedByValue([], usingComparator: cmptr)
501501
}
502502

503-
open func keysSortedByValue(_ opts: SortOptions = [], usingComparator cmptr: @noescape (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
503+
open func keysSortedByValue(_ opts: SortOptions = [], usingComparator cmptr: (AnyObject, AnyObject) -> ComparisonResult) -> [AnyObject] {
504504
let sorted = allKeys.sorted { lhs, rhs in
505505
return cmptr(lhs, rhs) == .orderedSame
506506
}
507507
return sorted
508508
}
509509

510-
open func keysOfEntries(passingTest predicate: @noescape (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Set<NSObject> {
510+
open func keysOfEntries(passingTest predicate: (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Set<NSObject> {
511511
return keysOfEntries([], passingTest: predicate)
512512
}
513513

514-
open func keysOfEntries(_ opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Set<NSObject> {
514+
open func keysOfEntries(_ opts: EnumerationOptions = [], passingTest predicate: (AnyObject, AnyObject, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Set<NSObject> {
515515
var matching = Set<NSObject>()
516516
enumerateKeysAndObjects(opts) { key, value, stop in
517517
if predicate(key, value, stop) {

0 commit comments

Comments
 (0)