Skip to content

Commit 1a7ff3f

Browse files
authored
Merge pull request swiftlang#154 from slavapestov/update-for-SE-0103
Attempt to update for SE-0103 (@NoEscape by default)
2 parents 5526122 + 95875d7 commit 1a7ff3f

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/swift/Block.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class DispatchWorkItem {
5353

5454
// Used by DispatchQueue.synchronously<T> to provide a @noescape path through
5555
// dispatch_block_t, as we know the lifetime of the block in question.
56-
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: @noescape () -> ()) {
56+
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
5757
_block = _swift_dispatch_block_create_noescape(dispatch_block_flags_t(flags.rawValue), noescapeBlock)
5858
}
5959

@@ -108,4 +108,4 @@ internal typealias _DispatchBlock = @convention(block) () -> Void
108108
internal typealias dispatch_block_t = @convention(block) () -> Void
109109

110110
@_silgen_name("_swift_dispatch_block_create_noescape")
111-
internal func _swift_dispatch_block_create_noescape(_ flags: dispatch_block_flags_t, _ block: @noescape () -> ()) -> _DispatchBlock
111+
internal func _swift_dispatch_block_create_noescape(_ flags: dispatch_block_flags_t, _ block: () -> ()) -> _DispatchBlock

src/swift/Data.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public struct DispatchData : RandomAccessCollection {
7474
}
7575

7676
public func withUnsafeBytes<Result, ContentType>(
77-
body: @noescape (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
77+
body: (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
7878
{
7979
var ptr: UnsafeRawPointer? = nil
8080
var size = 0
@@ -86,7 +86,7 @@ public struct DispatchData : RandomAccessCollection {
8686
}
8787

8888
public func enumerateBytes(
89-
block: @noescape (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
89+
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
9090
{
9191
_swift_dispatch_data_apply(__wrapped.__wrapped) { (data: dispatch_data_t, offset: Int, ptr: UnsafeRawPointer, size: Int) in
9292
let bytePtr = ptr.bindMemory(to: UInt8.self, capacity: size)
@@ -271,7 +271,7 @@ public struct DispatchDataIterator : IteratorProtocol, Sequence {
271271
internal var _position: DispatchData.Index
272272
}
273273

274-
typealias _swift_data_applier = @convention(block) @noescape (dispatch_data_t, Int, UnsafeRawPointer, Int) -> Bool
274+
typealias _swift_data_applier = @convention(block) (dispatch_data_t, Int, UnsafeRawPointer, Int) -> Bool
275275

276276
@_silgen_name("_swift_dispatch_data_apply")
277277
internal func _swift_dispatch_data_apply(_ data: dispatch_data_t, _ block: _swift_data_applier)

src/swift/Private.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,43 @@ public func dispatch_queue_create_with_target(_ label: UnsafePointer<Int8>?, _ a
2727
}
2828

2929
@available(*, unavailable, renamed:"DispatchIO.init(type:fileDescriptor:queue:cleanupHandler:)")
30-
public func dispatch_io_create(_ type: UInt, _ fd: Int32, _ queue: DispatchQueue, _ cleanup_handler: (Int32) -> Void) -> DispatchIO
30+
public func dispatch_io_create(_ type: UInt, _ fd: Int32, _ queue: DispatchQueue, _ cleanup_handler: @escaping (Int32) -> Void) -> DispatchIO
3131
{
3232
fatalError()
3333
}
3434

3535
@available(*, unavailable, renamed:"DispatchIO.init(type:path:oflag:mode:queue:cleanupHandler:)")
36-
public func dispatch_io_create_with_path(_ type: UInt, _ path: UnsafePointer<Int8>, _ oflag: Int32, _ mode: mode_t, _ queue: DispatchQueue, _ cleanup_handler: (Int32) -> Void) -> DispatchIO
36+
public func dispatch_io_create_with_path(_ type: UInt, _ path: UnsafePointer<Int8>, _ oflag: Int32, _ mode: mode_t, _ queue: DispatchQueue, _ cleanup_handler: @escaping (Int32) -> Void) -> DispatchIO
3737
{
3838
fatalError()
3939
}
4040

4141
@available(*, unavailable, renamed:"DispatchIO.init(type:io:queue:cleanupHandler:)")
42-
public func dispatch_io_create_with_io(_ type: UInt, _ io: DispatchIO, _ queue: DispatchQueue, _ cleanup_handler: (Int32) -> Void) -> DispatchIO
42+
public func dispatch_io_create_with_io(_ type: UInt, _ io: DispatchIO, _ queue: DispatchQueue, _ cleanup_handler: @escaping (Int32) -> Void) -> DispatchIO
4343
{
4444
fatalError()
4545
}
4646

4747
@available(*, unavailable, renamed:"DispatchIO.read(fileDescriptor:length:queue:handler:)")
48-
public func dispatch_read(_ fd: Int32, _ length: Int, _ queue: DispatchQueue, _ handler: (dispatch_data_t, Int32) -> Void)
48+
public func dispatch_read(_ fd: Int32, _ length: Int, _ queue: DispatchQueue, _ handler: @escaping (dispatch_data_t, Int32) -> Void)
4949
{
5050
fatalError()
5151
}
5252

5353
@available(*, unavailable, renamed:"DispatchIO.read(self:offset:length:queue:ioHandler:)")
54-
func dispatch_io_read(_ channel: DispatchIO, _ offset: off_t, _ length: Int, _ queue: DispatchQueue, _ io_handler: (Bool, dispatch_data_t?, Int32) -> Void)
54+
func dispatch_io_read(_ channel: DispatchIO, _ offset: off_t, _ length: Int, _ queue: DispatchQueue, _ io_handler: @escaping (Bool, dispatch_data_t?, Int32) -> Void)
5555
{
5656
fatalError()
5757
}
5858

5959
@available(*, unavailable, renamed:"DispatchIO.write(self:offset:data:queue:ioHandler:)")
60-
func dispatch_io_write(_ channel: DispatchIO, _ offset: off_t, _ data: dispatch_data_t, _ queue: DispatchQueue, _ io_handler: (Bool, dispatch_data_t?, Int32) -> Void)
60+
func dispatch_io_write(_ channel: DispatchIO, _ offset: off_t, _ data: dispatch_data_t, _ queue: DispatchQueue, _ io_handler: @escaping (Bool, dispatch_data_t?, Int32) -> Void)
6161
{
6262
fatalError()
6363
}
6464

6565
@available(*, unavailable, renamed:"DispatchIO.write(fileDescriptor:data:queue:handler:)")
66-
func dispatch_write(_ fd: Int32, _ data: dispatch_data_t, _ queue: DispatchQueue, _ handler: (dispatch_data_t?, Int32) -> Void)
66+
func dispatch_write(_ fd: Int32, _ data: dispatch_data_t, _ queue: DispatchQueue, _ handler: @escaping (dispatch_data_t?, Int32) -> Void)
6767
{
6868
fatalError()
6969
}
@@ -99,7 +99,7 @@ public func dispatch_data_create_subrange(_ data: dispatch_data_t, _ offset: Int
9999
}
100100

101101
@available(*, unavailable, renamed:"DispatchData.enumerateBytes(self:block:)")
102-
public func dispatch_data_apply(_ data: dispatch_data_t, _ applier: (dispatch_data_t, Int, UnsafeRawPointer, Int) -> Bool) -> Bool
102+
public func dispatch_data_apply(_ data: dispatch_data_t, _ applier: @escaping (dispatch_data_t, Int, UnsafeRawPointer, Int) -> Bool) -> Bool
103103
{
104104
fatalError()
105105
}
@@ -111,13 +111,13 @@ public func dispatch_data_copy_region(_ data: dispatch_data_t, _ location: Int,
111111
}
112112

113113
@available(*, unavailable, renamed:"DispatchQueue.asynchronously(self:group:qos:flags:execute:)")
114-
public func dispatch_group_async(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: () -> Void)
114+
public func dispatch_group_async(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: @escaping () -> Void)
115115
{
116116
fatalError()
117117
}
118118

119119
@available(*, unavailable, renamed: "DispatchGroup.notify(self:qos:flags:queue:execute:)")
120-
public func dispatch_group_notify(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: () -> Void)
120+
public func dispatch_group_notify(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: @escaping () -> Void)
121121
{
122122
fatalError()
123123
}
@@ -141,13 +141,13 @@ public func dispatch_io_set_interval(_ channel: DispatchIO, _ interval: UInt64,
141141
}
142142

143143
@available(*, unavailable, renamed:"DispatchQueue.apply(attributes:iterations:execute:)")
144-
public func dispatch_apply(_ iterations: Int, _ queue: DispatchQueue, _ block: @noescape (Int) -> Void)
144+
public func dispatch_apply(_ iterations: Int, _ queue: DispatchQueue, _ block: (Int) -> Void)
145145
{
146146
fatalError()
147147
}
148148

149149
@available(*, unavailable, renamed:"DispatchQueue.asynchronously(self:execute:)")
150-
public func dispatch_async(_ queue: DispatchQueue, _ block: () -> Void)
150+
public func dispatch_async(_ queue: DispatchQueue, _ block: @escaping () -> Void)
151151
{
152152
fatalError()
153153
}
@@ -195,19 +195,19 @@ public func dispatch_queue_get_qos_class(_ queue: DispatchQueue, _ relative_prio
195195
}
196196

197197
@available(*, unavailable, renamed:"DispatchQueue.after(self:when:execute:)")
198-
public func dispatch_after(_ when: dispatch_time_t, _ queue: DispatchQueue, _ block: () -> Void)
198+
public func dispatch_after(_ when: dispatch_time_t, _ queue: DispatchQueue, _ block: @escaping () -> Void)
199199
{
200200
fatalError()
201201
}
202202

203203
@available(*, unavailable, renamed:"DispatchQueue.asynchronously(self:group:qos:flags:execute:)")
204-
public func dispatch_barrier_async(_ queue: DispatchQueue, _ block: () -> Void)
204+
public func dispatch_barrier_async(_ queue: DispatchQueue, _ block: @escaping () -> Void)
205205
{
206206
fatalError()
207207
}
208208

209209
@available(*, unavailable, renamed:"DispatchQueue.synchronously(self:flags:execute:)")
210-
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: @noescape () -> Void)
210+
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: () -> Void)
211211
{
212212
fatalError()
213213
}

src/swift/Queue.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public extension DispatchQueue {
130130
}
131131
}
132132

133-
public class func concurrentPerform(iterations: Int, execute work: @noescape (Int) -> Void) {
133+
public class func concurrentPerform(iterations: Int, execute work: (Int) -> Void) {
134134
_swift_dispatch_apply_current(iterations, work)
135135
}
136136

@@ -229,7 +229,7 @@ public extension DispatchQueue {
229229
return
230230
}
231231

232-
var block: @escaping @convention(block) () -> Void = work
232+
var block: @convention(block) () -> Void = work
233233
if #available(OSX 10.10, iOS 8.0, *), (qos != .unspecified || !flags.isEmpty) {
234234
let workItem = DispatchWorkItem(qos: qos, flags: flags, block: work)
235235
block = workItem._block
@@ -242,13 +242,13 @@ public extension DispatchQueue {
242242
}
243243
}
244244

245-
private func _syncBarrier(block: @noescape () -> ()) {
245+
private func _syncBarrier(block: () -> ()) {
246246
CDispatch.dispatch_barrier_sync(self.__wrapped, block)
247247
}
248248

249249
private func _syncHelper<T>(
250-
fn: (@noescape () -> ()) -> (),
251-
execute work: @noescape () throws -> T,
250+
fn: (() -> ()) -> (),
251+
execute work: () throws -> T,
252252
rescue: ((Swift.Error) throws -> (T))) rethrows -> T
253253
{
254254
var result: T?
@@ -271,8 +271,8 @@ public extension DispatchQueue {
271271
private func _syncHelper<T>(
272272
fn: (DispatchWorkItem) -> (),
273273
flags: DispatchWorkItemFlags,
274-
execute work: @noescape () throws -> T,
275-
rescue: ((Swift.Error) throws -> (T))) rethrows -> T
274+
execute work: () throws -> T,
275+
rescue: @escaping ((Swift.Error) throws -> (T))) rethrows -> T
276276
{
277277
var result: T?
278278
var error: Swift.Error?
@@ -291,11 +291,11 @@ public extension DispatchQueue {
291291
}
292292
}
293293

294-
public func sync<T>(execute work: @noescape () throws -> T) rethrows -> T {
294+
public func sync<T>(execute work: () throws -> T) rethrows -> T {
295295
return try self._syncHelper(fn: sync, execute: work, rescue: { throw $0 })
296296
}
297297

298-
public func sync<T>(flags: DispatchWorkItemFlags, execute work: @noescape () throws -> T) rethrows -> T {
298+
public func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T {
299299
if flags == .barrier {
300300
return try self._syncHelper(fn: _syncBarrier, execute: work, rescue: { throw $0 })
301301
} else if #available(OSX 10.10, iOS 8.0, *), !flags.isEmpty {
@@ -385,4 +385,4 @@ internal func _swift_dispatch_get_main_queue() -> dispatch_queue_t
385385
internal func _swift_dispatch_apply_current_root_queue() -> dispatch_queue_t
386386

387387
@_silgen_name("_swift_dispatch_apply_current")
388-
internal func _swift_dispatch_apply_current(_ iterations: Int, _ block: @convention(block) @noescape (Int) -> Void)
388+
internal func _swift_dispatch_apply_current(_ iterations: Int, _ block: @convention(block) (Int) -> Void)

0 commit comments

Comments
 (0)