Skip to content

Attempt to update for SE-0103 (@noescape by default) #154

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 18, 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
4 changes: 2 additions & 2 deletions src/swift/Block.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class DispatchWorkItem {

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

Expand Down Expand Up @@ -108,4 +108,4 @@ internal typealias _DispatchBlock = @convention(block) () -> Void
internal typealias dispatch_block_t = @convention(block) () -> Void

@_silgen_name("_swift_dispatch_block_create_noescape")
internal func _swift_dispatch_block_create_noescape(_ flags: dispatch_block_flags_t, _ block: @noescape () -> ()) -> _DispatchBlock
internal func _swift_dispatch_block_create_noescape(_ flags: dispatch_block_flags_t, _ block: () -> ()) -> _DispatchBlock
6 changes: 3 additions & 3 deletions src/swift/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct DispatchData : RandomAccessCollection {
}

public func withUnsafeBytes<Result, ContentType>(
body: @noescape (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
body: (UnsafePointer<ContentType>) throws -> Result) rethrows -> Result
{
var ptr: UnsafeRawPointer? = nil
var size = 0
Expand All @@ -86,7 +86,7 @@ public struct DispatchData : RandomAccessCollection {
}

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

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

@_silgen_name("_swift_dispatch_data_apply")
internal func _swift_dispatch_data_apply(_ data: dispatch_data_t, _ block: _swift_data_applier)
Expand Down
30 changes: 15 additions & 15 deletions src/swift/Private.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,43 @@ public func dispatch_queue_create_with_target(_ label: UnsafePointer<Int8>?, _ a
}

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

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

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

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

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

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

@available(*, unavailable, renamed:"DispatchIO.write(fileDescriptor:data:queue:handler:)")
func dispatch_write(_ fd: Int32, _ data: dispatch_data_t, _ queue: DispatchQueue, _ handler: (dispatch_data_t?, Int32) -> Void)
func dispatch_write(_ fd: Int32, _ data: dispatch_data_t, _ queue: DispatchQueue, _ handler: @escaping (dispatch_data_t?, Int32) -> Void)
{
fatalError()
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public func dispatch_data_create_subrange(_ data: dispatch_data_t, _ offset: Int
}

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

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

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

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

@available(*, unavailable, renamed:"DispatchQueue.asynchronously(self:execute:)")
public func dispatch_async(_ queue: DispatchQueue, _ block: () -> Void)
public func dispatch_async(_ queue: DispatchQueue, _ block: @escaping () -> Void)
{
fatalError()
}
Expand Down Expand Up @@ -195,19 +195,19 @@ public func dispatch_queue_get_qos_class(_ queue: DispatchQueue, _ relative_prio
}

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

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

@available(*, unavailable, renamed:"DispatchQueue.synchronously(self:flags:execute:)")
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: @noescape () -> Void)
public func dispatch_barrier_sync(_ queue: DispatchQueue, _ block: () -> Void)
{
fatalError()
}
Expand Down
20 changes: 10 additions & 10 deletions src/swift/Queue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public extension DispatchQueue {
}
}

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

Expand Down Expand Up @@ -229,7 +229,7 @@ public extension DispatchQueue {
return
}

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

private func _syncBarrier(block: @noescape () -> ()) {
private func _syncBarrier(block: () -> ()) {
CDispatch.dispatch_barrier_sync(self.__wrapped, block)
}

private func _syncHelper<T>(
fn: (@noescape () -> ()) -> (),
execute work: @noescape () throws -> T,
fn: (() -> ()) -> (),
execute work: () throws -> T,
rescue: ((Swift.Error) throws -> (T))) rethrows -> T
{
var result: T?
Expand All @@ -271,8 +271,8 @@ public extension DispatchQueue {
private func _syncHelper<T>(
fn: (DispatchWorkItem) -> (),
flags: DispatchWorkItemFlags,
execute work: @noescape () throws -> T,
rescue: ((Swift.Error) throws -> (T))) rethrows -> T
execute work: () throws -> T,
rescue: @escaping ((Swift.Error) throws -> (T))) rethrows -> T
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rescue could be @noescape. I can't see nothing keeping a reference to it.

{
var result: T?
var error: Swift.Error?
Expand All @@ -291,11 +291,11 @@ public extension DispatchQueue {
}
}

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

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

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