From 833d206c7f03a42b049cc90d812d1a3ecd666f66 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 16 May 2017 19:28:59 -0700 Subject: [PATCH] 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. --- Foundation/Thread.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Foundation/Thread.swift b/Foundation/Thread.swift index 80b4d4c99d..3990db013e 100644 --- a/Foundation/Thread.swift +++ b/Foundation/Thread.swift @@ -24,7 +24,7 @@ private func _compiler_crash_fix(_ key: _CFThreadSpecificKey, _ value: AnyObject internal class NSThreadSpecific { private var key = _CFThreadSpecificKeyCreate() - internal func get(_ generator: (Void) -> T) -> T { + internal func get(_ generator: () -> T) -> T { if let specific = _CFThreadSpecificGet(key) { return specific as! T } else { @@ -130,7 +130,7 @@ open class Thread : NSObject { pthread_exit(nil) } - internal var _main: (Void) -> Void = {} + internal var _main: () -> Void = {} #if os(OSX) || os(iOS) || CYGWIN private var _thread: pthread_t? = nil #elseif os(Linux) || os(Android)