Skip to content

Commit 29bbd16

Browse files
committed
Attempt to update for SE-0103 (@NoEscape by default)
1 parent 045f499 commit 29bbd16

File tree

4 files changed

+37
-37
lines changed

4 files changed

+37
-37
lines changed

src/swift/Block.swift

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

4545
// Used by DispatchQueue.synchronously<T> to provide a @noescape path through
4646
// dispatch_block_t, as we know the lifetime of the block in question.
47-
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: @noescape () -> ()) {
47+
internal init(flags: DispatchWorkItemFlags = [], noescapeBlock: () -> ()) {
4848
_block = _swift_dispatch_block_create_noescape(__dispatch_block_flags_t(flags.rawValue), noescapeBlock)
4949
}
5050

@@ -112,20 +112,20 @@ internal typealias _DispatchBlock = @convention(block) () -> Void
112112
/// @convention(block) attributes. As such, all of the entry points are shimmed
113113
//// through Dispatch.mm with _DispatchBlock types.
114114
@_silgen_name("_swift_dispatch_block_create_with_qos_class")
115-
internal func _swift_dispatch_block_create_with_qos_class(_ flags: __dispatch_block_flags_t, _ qos: qos_class_t, _ relativePriority: Int32, _ block: _DispatchBlock) -> _DispatchBlock
115+
internal func _swift_dispatch_block_create_with_qos_class(_ flags: __dispatch_block_flags_t, _ qos: qos_class_t, _ relativePriority: Int32, _ block: @escaping _DispatchBlock) -> _DispatchBlock
116116

117117
@_silgen_name("_swift_dispatch_block_create_noescape")
118-
internal func _swift_dispatch_block_create_noescape(_ flags: __dispatch_block_flags_t, _ block: @noescape () -> ()) -> _DispatchBlock
118+
internal func _swift_dispatch_block_create_noescape(_ flags: __dispatch_block_flags_t, _ block: () -> ()) -> _DispatchBlock
119119

120120
@_silgen_name("_swift_dispatch_block_wait")
121-
internal func _swift_dispatch_block_wait(_ block: _DispatchBlock, _ timeout: UInt64) -> Int
121+
internal func _swift_dispatch_block_wait(_ block: @escaping _DispatchBlock, _ timeout: UInt64) -> Int
122122

123123
@_silgen_name("_swift_dispatch_block_notify")
124-
internal func _swift_dispatch_block_notify(_ block: _DispatchBlock, _ queue: DispatchQueue, _ notifier: _DispatchBlock)
124+
internal func _swift_dispatch_block_notify(_ block: @escaping _DispatchBlock, _ queue: DispatchQueue, _ notifier: @escaping _DispatchBlock)
125125

126126
@_silgen_name("_swift_dispatch_block_cancel")
127-
internal func _swift_dispatch_block_cancel(_ block: _DispatchBlock)
127+
internal func _swift_dispatch_block_cancel(_ block: @escaping _DispatchBlock)
128128
129129
@_silgen_name("_swift_dispatch_block_testcancel")
130-
internal func _swift_dispatch_block_testcancel(_ block: _DispatchBlock) -> Int
130+
internal func _swift_dispatch_block_testcancel(_ block: @escaping _DispatchBlock) -> Int
131131

src/swift/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ extension DispatchData {
284284
}
285285
}
286286

287-
typealias _swift_data_applier = @convention(block) @noescape (__DispatchData, Int, UnsafePointer<Void>, Int) -> Bool
287+
typealias _swift_data_applier = @convention(block) (__DispatchData, Int, UnsafePointer<Void>, Int) -> Bool
288288

289289
@_silgen_name("_swift_dispatch_data_apply")
290290
internal func _swift_dispatch_data_apply(_ data: __DispatchData, _ block: _swift_data_applier)

src/swift/Private.swift

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

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

3333
@available(*, unavailable, renamed:"DispatchIO.init(type:path:oflag:mode:queue:cleanupHandler:)")
34-
public func dispatch_io_create_with_path(_ type: UInt, _ path: UnsafePointer<Int8>, _ oflag: Int32, _ mode: mode_t, _ queue: DispatchQueue, _ cleanup_handler: (Int32) -> Void) -> DispatchIO
34+
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
3535
{
3636
fatalError()
3737
}
3838

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

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

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

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

6363
@available(*, unavailable, renamed:"DispatchIO.write(fileDescriptor:data:queue:handler:)")
64-
func dispatch_write(_ fd: Int32, _ data: __DispatchData, _ queue: DispatchQueue, _ handler: (__DispatchData?, Int32) -> Void)
64+
func dispatch_write(_ fd: Int32, _ data: __DispatchData, _ queue: DispatchQueue, _ handler: @escaping (__DispatchData?, Int32) -> Void)
6565
{
6666
fatalError()
6767
}
@@ -97,7 +97,7 @@ public func dispatch_data_create_subrange(_ data: __DispatchData, _ offset: Int,
9797
}
9898

9999
@available(*, unavailable, renamed:"DispatchData.enumerateBytes(self:block:)")
100-
public func dispatch_data_apply(_ data: __DispatchData, _ applier: (__DispatchData, Int, UnsafePointer<Void>, Int) -> Bool) -> Bool
100+
public func dispatch_data_apply(_ data: __DispatchData, _ applier: @escaping (__DispatchData, Int, UnsafePointer<Void>, Int) -> Bool) -> Bool
101101
{
102102
fatalError()
103103
}
@@ -109,13 +109,13 @@ public func dispatch_data_copy_region(_ data: __DispatchData, _ location: Int, _
109109
}
110110

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

117117
@available(*, unavailable, renamed: "DispatchGroup.notify(self:qos:flags:queue:execute:)")
118-
public func dispatch_group_notify(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: () -> Void)
118+
public func dispatch_group_notify(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: @escaping () -> Void)
119119
{
120120
fatalError()
121121
}
@@ -139,13 +139,13 @@ public func dispatch_io_set_interval(_ channel: DispatchIO, _ interval: UInt64,
139139
}
140140

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

147147
@available(*, unavailable, renamed:"DispatchQueue.asynchronously(self:execute:)")
148-
public func dispatch_async(_ queue: DispatchQueue, _ block: () -> Void)
148+
public func dispatch_async(_ queue: DispatchQueue, _ block: @escaping () -> Void)
149149
{
150150
fatalError()
151151
}
@@ -193,19 +193,19 @@ public func dispatch_queue_get_qos_class(_ queue: DispatchQueue, _ relative_prio
193193
}
194194

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

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

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

src/swift/Queue.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public extension DispatchQueue {
157157
}
158158
}
159159

160-
public class func concurrentPerform(iterations: Int, execute work: @noescape (Int) -> Void) {
160+
public class func concurrentPerform(iterations: Int, execute work: (Int) -> Void) {
161161
_swift_dispatch_apply_current(iterations, work)
162162
}
163163

@@ -238,13 +238,13 @@ public extension DispatchQueue {
238238
}
239239
}
240240

241-
private func _syncBarrier(block: @noescape () -> ()) {
241+
private func _syncBarrier(block: () -> ()) {
242242
__dispatch_barrier_sync(self, block)
243243
}
244244

245245
private func _syncHelper<T>(
246-
fn: (@noescape () -> ()) -> (),
247-
execute work: @noescape () throws -> T,
246+
fn: (() -> ()) -> (),
247+
execute work: () throws -> T,
248248
rescue: ((ErrorProtocol) throws -> (T))) rethrows -> T
249249
{
250250
var result: T?
@@ -267,7 +267,7 @@ public extension DispatchQueue {
267267
private func _syncHelper<T>(
268268
fn: (DispatchWorkItem) -> (),
269269
flags: DispatchWorkItemFlags,
270-
execute work: @noescape () throws -> T,
270+
execute work: () throws -> T,
271271
rescue: ((ErrorProtocol) throws -> (T))) rethrows -> T
272272
{
273273
var result: T?
@@ -287,11 +287,11 @@ public extension DispatchQueue {
287287
}
288288
}
289289

290-
public func sync<T>(execute work: @noescape () throws -> T) rethrows -> T {
290+
public func sync<T>(execute work: () throws -> T) rethrows -> T {
291291
return try self._syncHelper(fn: sync, execute: work, rescue: { throw $0 })
292292
}
293293

294-
public func sync<T>(flags: DispatchWorkItemFlags, execute work: @noescape () throws -> T) rethrows -> T {
294+
public func sync<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T {
295295
if flags == .barrier {
296296
return try self._syncHelper(fn: _syncBarrier, execute: work, rescue: { throw $0 })
297297
} else if #available(OSX 10.10, iOS 8.0, *), !flags.isEmpty {
@@ -357,7 +357,7 @@ public extension DispatchQueue {
357357

358358
extension DispatchQueue {
359359
@available(*, deprecated, renamed: "DispatchQueue.sync(self:execute:)")
360-
public func synchronously(execute work: @noescape () -> ()) {
360+
public func synchronously(execute work: () -> ()) {
361361
sync(execute: work)
362362
}
363363

@@ -381,17 +381,17 @@ extension DispatchQueue {
381381
}
382382

383383
@available(*, deprecated, renamed: "DispatchQueue.sync(self:execute:)")
384-
public func synchronously<T>(execute work: @noescape () throws -> T) rethrows -> T {
384+
public func synchronously<T>(execute work: () throws -> T) rethrows -> T {
385385
return try sync(execute: work)
386386
}
387387

388388
@available(*, deprecated, renamed: "DispatchQueue.sync(self:flags:execute:)")
389-
public func synchronously<T>(flags: DispatchWorkItemFlags, execute work: @noescape () throws -> T) rethrows -> T {
389+
public func synchronously<T>(flags: DispatchWorkItemFlags, execute work: () throws -> T) rethrows -> T {
390390
return try sync(flags: flags, execute: work)
391391
}
392392

393393
@available(*, deprecated, renamed: "DispatchQueue.concurrentPerform(iterations:execute:)")
394-
public func apply(applier iterations: Int, execute block: @noescape (Int) -> Void) {
394+
public func apply(applier iterations: Int, execute block: (Int) -> Void) {
395395
DispatchQueue.concurrentPerform(iterations: iterations, execute: block)
396396
}
397397

@@ -417,13 +417,13 @@ internal func _swift_dispatch_get_main_queue() -> DispatchQueue
417417
internal func _swift_dispatch_apply_current_root_queue() -> DispatchQueue
418418

419419
@_silgen_name("_swift_dispatch_async")
420-
internal func _swift_dispatch_async(_ queue: DispatchQueue, _ block: _DispatchBlock)
420+
internal func _swift_dispatch_async(_ queue: DispatchQueue, _ block: @escaping _DispatchBlock)
421421

422422
@_silgen_name("_swift_dispatch_group_async")
423-
internal func _swift_dispatch_group_async(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: _DispatchBlock)
423+
internal func _swift_dispatch_group_async(_ group: DispatchGroup, _ queue: DispatchQueue, _ block: @escaping _DispatchBlock)
424424

425425
@_silgen_name("_swift_dispatch_sync")
426426
internal func _swift_dispatch_sync(_ queue: DispatchQueue, _ block: _DispatchBlock)
427427

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

0 commit comments

Comments
 (0)