Skip to content

Remove deprecated @noescape which is now the default [SE-0103] #507

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
Aug 10, 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
12 changes: 6 additions & 6 deletions Foundation/Boxing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal final class _MutableHandle<MutableType : NSObject where MutableType : N
}

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

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

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

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

switch __wrapped {
Expand Down Expand Up @@ -141,7 +141,7 @@ internal protocol _MutablePairBoxing {

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

@inline(__always)
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : @noescape (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
mutating func _applyUnmanagedMutation<ReturnType>(_ whatToDo : (WrappedSwiftNSType.MutableType) throws -> ReturnType) rethrows -> ReturnType {
// We are using Unmananged. Make sure that the owning container class
// 'self' is guaranteed to be alive by extending the lifetime of 'self'
// to the end of the scope of this function.
Expand Down
8 changes: 4 additions & 4 deletions Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ internal final class _SwiftNSData : NSData, _SwiftNativeFoundationType {
// }
// }
//
// override func enumerateByteRanges(using block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
// override func enumerateByteRanges(using block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<ObjCBool>) -> Void) {
// return _mapUnmanaged { $0.enumerateBytes(block) }
// }
//
Expand Down Expand Up @@ -311,7 +311,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
/// Access the bytes in the data.
///
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
public func withUnsafeBytes<ResultType, ContentType>(_ body: @noescape (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
public func withUnsafeBytes<ResultType, ContentType>(_ body: (UnsafePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
let bytes = _getUnsafeBytesPointer()
defer { _fixLifetime(self)}
let contentPtr = bytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
Expand All @@ -328,7 +328,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
///
/// This function assumes that you are mutating the contents.
/// - warning: The byte pointer argument should not be stored and used outside of the lifetime of the call to the closure.
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: @noescape (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
public mutating func withUnsafeMutableBytes<ResultType, ContentType>(_ body: (UnsafeMutablePointer<ContentType>) throws -> ResultType) rethrows -> ResultType {
let mutableBytes = _getUnsafeMutableBytesPointer()
defer { _fixLifetime(self)}
let contentPtr = mutableBytes.bindMemory(to: ContentType.self, capacity: count / MemoryLayout<ContentType>.stride)
Expand Down Expand Up @@ -435,7 +435,7 @@ public struct Data : ReferenceConvertible, CustomStringConvertible, Equatable, H
///
/// 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.
/// - parameter block: The closure to invoke for each region of data. You may stop the enumeration by setting the `stop` parameter to `true`.
public func enumerateBytes(_ block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
public func enumerateBytes(_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Index, _ stop: inout Bool) -> Void) {
_mapUnmanaged {
$0.enumerateBytes { (ptr, range, stop) in
var stopv = false
Expand Down
6 changes: 3 additions & 3 deletions Foundation/IndexSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
///
/// - 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.
/// - parameter includeInteger: The predicate which decides if an integer will be included in the result or not.
public func filteredIndexSet(in range : Range<Element>? = nil, includeInteger: @noescape (Element) throws -> Bool) rethrows -> IndexSet {
public func filteredIndexSet(in range : Range<Element>? = nil, includeInteger: (Element) throws -> Bool) rethrows -> IndexSet {
let r : NSRange = range != nil ? _toNSRange(range!) : NSMakeRange(0, NSNotFound - 1)
return try _handle.map {
var error : Swift.Error? = nil
Expand Down Expand Up @@ -667,7 +667,7 @@ public struct IndexSet : ReferenceConvertible, Equatable, BidirectionalCollectio
// Temporary boxing function, until we can get a native Swift type for NSIndexSet
/// TODO: making this inline causes the compiler to crash horrifically.
// @inline(__always)
mutating func _applyMutation<ReturnType>(_ whatToDo : @noescape (NSMutableIndexSet) throws -> ReturnType) rethrows -> ReturnType {
mutating func _applyMutation<ReturnType>(_ whatToDo : (NSMutableIndexSet) throws -> ReturnType) rethrows -> ReturnType {
switch _handle._pointer {
case .Default(let i):
// We need to become mutable; by creating a new box we also become unique
Expand Down Expand Up @@ -845,7 +845,7 @@ private final class _MutablePairHandle<ImmutableType : NSObject, MutableType : N

/// Apply a closure to the reference type, regardless if it is mutable or immutable.
@inline(__always)
func map<ReturnType>(_ whatToDo : @noescape (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
func map<ReturnType>(_ whatToDo : (ImmutableType) throws -> ReturnType) rethrows -> ReturnType {
switch _pointer {
case .Default(let i):
return try whatToDo(i)
Expand Down
30 changes: 15 additions & 15 deletions Foundation/NSArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
}))
}

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

open func sortedArray(_ comparator: @noescape @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?, hint: Data?) -> [AnyObject] {
open func sortedArray(_ comparator: @convention(c) (AnyObject, AnyObject, UnsafeMutableRawPointer?) -> Int, context: UnsafeMutableRawPointer?, hint: Data?) -> [AnyObject] {
return sortedArray([]) { lhs, rhs in
return ComparisonResult(rawValue: comparator(lhs, rhs, context))!
}
Expand Down Expand Up @@ -429,13 +429,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
return object(at: idx)
}

public func enumerateObjects(_ block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
public func enumerateObjects(_ block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
self.enumerateObjects([], using: block)
}
public func enumerateObjects(_ opts: EnumerationOptions = [], using block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
public func enumerateObjects(_ opts: EnumerationOptions = [], using block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Swift.Void) {
self.enumerateObjects(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, using: block)
}
public func enumerateObjects(at s: IndexSet, options opts: EnumerationOptions = [], using block: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
public func enumerateObjects(at s: IndexSet, options opts: EnumerationOptions = [], using block: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Void) {
guard !opts.contains(.concurrent) else {
NSUnimplemented()
}
Expand All @@ -444,13 +444,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
}
}

open func indexOfObject(passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
open func indexOfObject(passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
return indexOfObject([], passingTest: predicate)
}
open func indexOfObject(_ opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
open func indexOfObject(_ opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
return indexOfObject(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, passingTest: predicate)
}
open func indexOfObject(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
open func indexOfObject(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> Int {
var result = NSNotFound
enumerateObjects(at: s, options: opts) { (obj, idx, stop) -> Void in
if predicate(obj, idx, stop) {
Expand All @@ -461,13 +461,13 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
return result
}

open func indexesOfObjects(passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
open func indexesOfObjects(passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
return indexesOfObjects([], passingTest: predicate)
}
open func indexesOfObjects(_ opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
open func indexesOfObjects(_ opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
return indexesOfObjects(at: IndexSet(indexesIn: NSMakeRange(0, count)), options: opts, passingTest: predicate)
}
open func indexesOfObjects(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: @noescape (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
open func indexesOfObjects(at s: IndexSet, options opts: EnumerationOptions = [], passingTest predicate: (AnyObject, Int, UnsafeMutablePointer<ObjCBool>) -> Bool) -> IndexSet {
var result = IndexSet()
enumerateObjects(at: s, options: opts) { (obj, idx, stop) in
if predicate(obj, idx, stop) {
Expand All @@ -477,7 +477,7 @@ open class NSArray : NSObject, NSCopying, NSMutableCopying, NSSecureCoding, NSCo
return result
}

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

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

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

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

// argument validation
Expand Down
2 changes: 1 addition & 1 deletion Foundation/NSCoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ open class NSCoder : NSObject {
}
*/
/// - experimental: This method does not exist in the Darwin Foundation.
open func withDecodedUnsafeBufferPointer<ResultType>(forKey key: String, body: @noescape (UnsafeBufferPointer<UInt8>?) throws -> ResultType) rethrows -> ResultType {
open func withDecodedUnsafeBufferPointer<ResultType>(forKey key: String, body: (UnsafeBufferPointer<UInt8>?) throws -> ResultType) rethrows -> ResultType {
NSRequiresConcreteImplementation()
}

Expand Down
4 changes: 2 additions & 2 deletions Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ extension NSData {
return nil
}

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

public func enumerateBytes(_ block: @noescape (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) -> Void) {
public func enumerateBytes(_ block: (UnsafeRawPointer, NSRange, UnsafeMutablePointer<Bool>) -> Void) {
var stop = false
withUnsafeMutablePointer(to: &stop) { stopPointer in
block(bytes, NSMakeRange(0, length), stopPointer)
Expand Down
12 changes: 6 additions & 6 deletions Foundation/NSDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,11 @@ open class NSDictionary : NSObject, NSCopying, NSMutableCopying, NSSecureCoding,
open func write(toFile path: String, atomically useAuxiliaryFile: Bool) -> Bool { NSUnimplemented() }
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.

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

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

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

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

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

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