Skip to content

Commit b79bbb5

Browse files
committed
fixes for swiftc compiler warnings
1. @NoEscape is now the default for blocks (and is deprecated) 2. unreachable default in switch statement
1 parent ab16f5e commit b79bbb5

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
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: 2 additions & 2 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)

src/swift/Dispatch.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public struct DispatchQoS : Equatable {
9696
case .QOS_CLASS_USER_INITIATED: self = .userInitiated
9797
case .QOS_CLASS_USER_INTERACTIVE: self = .userInteractive
9898
case .QOS_CLASS_UNSPECIFIED: self = .unspecified
99-
default: return nil
10099
}
101100
}
102101

src/swift/Private.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ 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
}
@@ -207,7 +207,7 @@ public func dispatch_barrier_async(_ queue: DispatchQueue, _ block: () -> Void)
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: 8 additions & 8 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

@@ -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,7 +271,7 @@ public extension DispatchQueue {
271271
private func _syncHelper<T>(
272272
fn: (DispatchWorkItem) -> (),
273273
flags: DispatchWorkItemFlags,
274-
execute work: @noescape () throws -> T,
274+
execute work: () throws -> T,
275275
rescue: ((Swift.Error) throws -> (T))) rethrows -> T
276276
{
277277
var result: T?
@@ -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)

src/swift/Wrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class DispatchQueue : DispatchObject {
153153
_swift_dispatch_release(wrapped())
154154
}
155155

156-
public func sync(execute workItem: @noescape ()->()) {
156+
public func sync(execute workItem: ()->()) {
157157
dispatch_sync(self.__wrapped, workItem)
158158
}
159159
}

0 commit comments

Comments
 (0)