Skip to content

Commit fca7b66

Browse files
authored
Merge pull request #6521 from jpsim/jp-void-return
[gardening] prefer '-> Void' over '-> ()' in stdlib source
2 parents eb78182 + ea5b665 commit fca7b66

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

stdlib/private/StdlibUnittest/RaceTest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ public func consumeCPU(units amountOfWork: Int) {
678678
}
679679

680680
internal struct ClosureBasedRaceTest : RaceTestWithPerTrialData {
681-
static var thread: () -> () = {}
681+
static var thread: () -> Void = {}
682682

683683
class RaceData {}
684684
typealias ThreadLocalData = Void
@@ -703,7 +703,7 @@ public func runRaceTest(
703703
trials: Int,
704704
timeoutInSeconds: Int? = nil,
705705
threads: Int? = nil,
706-
invoking body: @escaping () -> ()
706+
invoking body: @escaping () -> Void
707707
) {
708708
ClosureBasedRaceTest.thread = body
709709
runRaceTest(ClosureBasedRaceTest.self, trials: trials,
@@ -714,7 +714,7 @@ public func runRaceTest(
714714
operations: Int,
715715
timeoutInSeconds: Int? = nil,
716716
threads: Int? = nil,
717-
invoking body: @escaping () -> ()
717+
invoking body: @escaping () -> Void
718718
) {
719719
ClosureBasedRaceTest.thread = body
720720
runRaceTest(ClosureBasedRaceTest.self, operations: operations,

stdlib/private/SwiftReflectionTest/SwiftReflectionTest.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -394,22 +394,22 @@ public func reflect<T: Error>(error: T) {
394394

395395
/// Wraps a thick function with arity 0.
396396
struct ThickFunction0 {
397-
var function: () -> ()
397+
var function: () -> Void
398398
}
399399

400400
/// Wraps a thick function with arity 1.
401401
struct ThickFunction1 {
402-
var function: (Int) -> ()
402+
var function: (Int) -> Void
403403
}
404404

405405
/// Wraps a thick function with arity 2.
406406
struct ThickFunction2 {
407-
var function: (Int, String) -> ()
407+
var function: (Int, String) -> Void
408408
}
409409

410410
/// Wraps a thick function with arity 3.
411411
struct ThickFunction3 {
412-
var function: (Int, String, AnyObject?) -> ()
412+
var function: (Int, String, AnyObject?) -> Void
413413
}
414414

415415
struct ThickFunctionParts {
@@ -419,7 +419,7 @@ struct ThickFunctionParts {
419419

420420
/// Reflect a closure context. The given function must be a Swift-native
421421
/// @convention(thick) function value.
422-
public func reflect(function: @escaping () -> ()) {
422+
public func reflect(function: @escaping () -> Void) {
423423
let fn = UnsafeMutablePointer<ThickFunction0>.allocate(
424424
capacity: MemoryLayout<ThickFunction0>.size)
425425
fn.initialize(to: ThickFunction0(function: function))
@@ -434,7 +434,7 @@ public func reflect(function: @escaping () -> ()) {
434434

435435
/// Reflect a closure context. The given function must be a Swift-native
436436
/// @convention(thick) function value.
437-
public func reflect(function: @escaping (Int) -> ()) {
437+
public func reflect(function: @escaping (Int) -> Void) {
438438
let fn =
439439
UnsafeMutablePointer<ThickFunction1>.allocate(
440440
capacity: MemoryLayout<ThickFunction1>.size)
@@ -450,7 +450,7 @@ public func reflect(function: @escaping (Int) -> ()) {
450450

451451
/// Reflect a closure context. The given function must be a Swift-native
452452
/// @convention(thick) function value.
453-
public func reflect(function: @escaping (Int, String) -> ()) {
453+
public func reflect(function: @escaping (Int, String) -> Void) {
454454
let fn = UnsafeMutablePointer<ThickFunction2>.allocate(
455455
capacity: MemoryLayout<ThickFunction2>.size)
456456
fn.initialize(to: ThickFunction2(function: function))
@@ -465,7 +465,7 @@ public func reflect(function: @escaping (Int, String) -> ()) {
465465

466466
/// Reflect a closure context. The given function must be a Swift-native
467467
/// @convention(thick) function value.
468-
public func reflect(function: @escaping (Int, String, AnyObject?) -> ()) {
468+
public func reflect(function: @escaping (Int, String, AnyObject?) -> Void) {
469469
let fn = UnsafeMutablePointer<ThickFunction3>.allocate(
470470
capacity: MemoryLayout<ThickFunction3>.size)
471471
fn.initialize(to: ThickFunction3(function: function))

stdlib/public/SDK/Dispatch/Block.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ public struct DispatchWorkItemFlags : OptionSet, RawRepresentable {
3838
public class DispatchWorkItem {
3939
internal var _block: _DispatchBlock
4040

41-
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> ()) {
41+
public init(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], block: @escaping @convention(block) () -> Void) {
4242
_block = _swift_dispatch_block_create_with_qos_class(
4343
__dispatch_block_flags_t(rawValue: flags.rawValue),
4444
qos.qosClass.rawValue, Int32(qos.relativePriority), block)
4545
}
4646

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

stdlib/public/SDK/Dispatch/Dispatch.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public enum DispatchTimeoutResult {
130130
/// dispatch_group
131131

132132
public extension DispatchGroup {
133-
public func notify(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], queue: DispatchQueue, execute work: @escaping @convention(block) () -> ()) {
133+
public func notify(qos: DispatchQoS = .unspecified, flags: DispatchWorkItemFlags = [], queue: DispatchQueue, execute work: @escaping @convention(block) () -> Void) {
134134
if #available(OSX 10.10, iOS 8.0, *), qos != .unspecified || !flags.isEmpty {
135135
let item = DispatchWorkItem(qos: qos, flags: flags, block: work)
136136
_swift_dispatch_group_notify(self, queue, item._block)

stdlib/public/SDK/Dispatch/Queue.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ public extension DispatchQueue {
221221
}
222222
}
223223

224-
private func _syncBarrier(block: () -> ()) {
224+
private func _syncBarrier(block: () -> Void) {
225225
__dispatch_barrier_sync(self, block)
226226
}
227227

228228
private func _syncHelper<T>(
229-
fn: (() -> ()) -> (),
229+
fn: (() -> Void) -> Void,
230230
execute work: () throws -> T,
231231
rescue: ((Error) throws -> (T))) rethrows -> T
232232
{
@@ -248,7 +248,7 @@ public extension DispatchQueue {
248248

249249
@available(OSX 10.10, iOS 8.0, *)
250250
private func _syncHelper<T>(
251-
fn: (DispatchWorkItem) -> (),
251+
fn: (DispatchWorkItem) -> Void,
252252
flags: DispatchWorkItemFlags,
253253
execute work: () throws -> T,
254254
rescue: ((Error) throws -> (T))) rethrows -> T

stdlib/public/SDK/Foundation/Data.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
14291429
let shift = resultCount - currentCount
14301430
let start = subrange.lowerBound
14311431

1432-
self.withUnsafeMutableBytes { (bytes : UnsafeMutablePointer<UInt8>) -> () in
1432+
self.withUnsafeMutableBytes { (bytes : UnsafeMutablePointer<UInt8>) -> Void in
14331433
if shift != 0 {
14341434
let destination = bytes + start + replacementCount
14351435
let source = bytes + start + subrangeCount

stdlib/public/SDK/Foundation/NSStringAPI.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ extension String {
468468

469469
/// Enumerates all the lines in a string.
470470
public func enumerateLines(
471-
invoking body: @escaping (_ line: String, _ stop: inout Bool) -> ()
471+
invoking body: @escaping (_ line: String, _ stop: inout Bool) -> Void
472472
) {
473473
_ns.enumerateLines {
474474
(line: String, stop: UnsafeMutablePointer<ObjCBool>)
@@ -501,7 +501,7 @@ extension String {
501501
options opts: NSLinguisticTagger.Options = [],
502502
orthography: NSOrthography? = nil,
503503
invoking body:
504-
(String, Range<Index>, Range<Index>, inout Bool) -> ()
504+
(String, Range<Index>, Range<Index>, inout Bool) -> Void
505505
) {
506506
_ns.enumerateLinguisticTags(
507507
in: _toNSRange(range),
@@ -536,7 +536,7 @@ extension String {
536536
_ body: @escaping (
537537
_ substring: String?, _ substringRange: Range<Index>,
538538
_ enclosingRange: Range<Index>, inout Bool
539-
) -> ()
539+
) -> Void
540540
) {
541541
_ns.enumerateSubstrings(in: _toNSRange(range), options: opts) {
542542
var stop_ = false
@@ -1736,7 +1736,7 @@ extension String {
17361736
options opts: NSLinguisticTagger.Options,
17371737
orthography: NSOrthography?,
17381738
_ body:
1739-
(String, Range<Index>, Range<Index>, inout Bool) -> ()
1739+
(String, Range<Index>, Range<Index>, inout Bool) -> Void
17401740
) {
17411741
fatalError("unavailable function can't be called")
17421742
}
@@ -1748,7 +1748,7 @@ extension String {
17481748
_ body: (
17491749
_ substring: String?, _ substringRange: Range<Index>,
17501750
_ enclosingRange: Range<Index>, inout Bool
1751-
) -> ()
1751+
) -> Void
17521752
) {
17531753
fatalError("unavailable function can't be called")
17541754
}

0 commit comments

Comments
 (0)