Skip to content

Commit 833d206

Browse files
committed
Small cleanup: Use () -> ... instead of (Void) -> ... for no-argument closures
In Swift, (Void) -> Void is actually a function that takes a single value of empty-tuple type, and not a function that takes no arguments. Swift 3 largely ignored the distinction because of the implicit 'tuple splat' behavior; in Swift 4, this behavior has been eliminated as part of implementing SE-0110, so calling a function of type (Void) -> () now requires passing in an empty tuple, like foo(()). I believe this is not intended behavior, so this patch changes the functions in question to be written as () -> Void.
1 parent 5a0e57d commit 833d206

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Foundation/Thread.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private func _compiler_crash_fix(_ key: _CFThreadSpecificKey, _ value: AnyObject
2424
internal class NSThreadSpecific<T: NSObject> {
2525
private var key = _CFThreadSpecificKeyCreate()
2626

27-
internal func get(_ generator: (Void) -> T) -> T {
27+
internal func get(_ generator: () -> T) -> T {
2828
if let specific = _CFThreadSpecificGet(key) {
2929
return specific as! T
3030
} else {
@@ -130,7 +130,7 @@ open class Thread : NSObject {
130130
pthread_exit(nil)
131131
}
132132

133-
internal var _main: (Void) -> Void = {}
133+
internal var _main: () -> Void = {}
134134
#if os(OSX) || os(iOS) || CYGWIN
135135
private var _thread: pthread_t? = nil
136136
#elseif os(Linux) || os(Android)

0 commit comments

Comments
 (0)