Skip to content

Small cleanup: Use () -> ... instead of (Void) -> ... for no-argument closures #984

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
May 23, 2017

Conversation

slavapestov
Copy link
Contributor

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.

… 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.
@slavapestov
Copy link
Contributor Author

@parkera Does this look OK?

@parkera
Copy link
Contributor

parkera commented May 17, 2017

Yup, thanks.

@mattrajca
Copy link
Contributor

@slavapestov how are you able to build swift-corelibs-foundation with Swift 4/master? I get hundreds of build errors due to renamed APIs and bit shifts not being available apparently.

@e78l
Copy link
Contributor

e78l commented May 17, 2017

@mattrajca Could you confirm the platform you're building for? Ubuntu 16.10? I haven't seen NSGeometry errors you described in the email. Are you using the swift/util/build script - or maybe you're building against a snapshot somehow?

@mattrajca
Copy link
Contributor

@e78l I am using utils/build-script with -r --foundation --xctest -t and using Xcode 8.3.2 on macOS 10.12.4. I also tried using the standard toolchain as well as the latest Swift 4 snapshot.

@pushkarnk
Copy link
Member

@mattrajca #988 is expected to fix the build errors on macOS (this thread)

@pushkarnk
Copy link
Member

I think this is can be merged. It will eliminate a warning that we're seeing in the Foundation builds.

@pushkarnk
Copy link
Member

@swift-ci please test and merge

@swift-ci swift-ci merged commit 1a97528 into swiftlang:master May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants