Swift 1.2: New one-line closure behavior erroneously prefers Void return

Originator:zwaldowski
Number:rdar://19776288 Date Originated:09-Feb-2015
Status:Closed Resolved:true
Product:Developer Tools Product Version:Xcode Version 6.3 (6D520o)
Classification:Other Bug Reproducible:Sometimes
 
Summary:
The 6.3 seed 1 release notes indicate: "Unannotated single-expression closures with non-Void return types can now be used in Void contexts."

This behavior is great, though I have observed it acting a bit… over-zealous.

Steps to Reproduce:
1. Overload two methods, one that takes a 
2. Call that method with a one-line closure that unambiguously returns a value.
3. Observe that the "-> Void" version is preferred.

Expected Results:
This is a regression from Swift 1.1. Swift should choose Void-returning versions after exhausting more compatible versions.

Actual Results:
Swift resolves to the Void-returning version.

Version:
/OS X Version 10.10.3 (14D72i)/Xcode Version 6.3 (6D520o)

Notes:
Workarounds include not using closures (in the example above, just passing the free function "count" works) and/or disambiguating the overloads manually. If map were implemented as an operator or free function, similar issues occur.

Configuration:


Attachments:
'TryForVoid.playground.zip' was successfully uploaded.

Comments

Thanks!

This issue has been verified as resolved and can be closed.

By zwaldowski at Feb. 23, 2015, 11:54 p.m. (reply...)

From Apple Developer Relations, 23-Feb-2015 11:05 AM:

We believe this issue has been addressed in the latest Xcode 6.3 beta 2, including iOS 8.3 SDK with Swift 1.2.

Please test with this release. If you still have issues, please include any relevant logs or information that could help us investigate.

This is a pre-release version of the complete Xcode developer toolset for Mac, iPhone, iPad, and Apple Watch. This release requires OS X Yosemite.

Xcode 6.3 beta 2 https://developer.apple.com/xcode/downloads/

By zwaldowski at Feb. 23, 2015, 11:52 p.m. (reply...)

Attachment in Gist form: https://gist.github.com/zwaldowski/87515eadb1face8965a1

By zwaldowski at Feb. 10, 2015, 2:43 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!