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
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!
Thanks!
This issue has been verified as resolved and can be closed.
From Apple Developer Relations, 23-Feb-2015 11:05 AM:
Attachment in Gist form: https://gist.github.com/zwaldowski/87515eadb1face8965a1