Swift: Incorrect compiler error message when returning Void? from a closure
| Originator: | getaaron | ||
| Number: | rdar://19374416 | Date Originated: | 05-Jan-2015 11:45 AM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | Xcode Version 6.2 (6C95a) |
| Classification: | Security | Reproducible: | Always |
Summary:
When using a closure that calls an optional method, an incorrect compiler message can be displayed.
Steps to Reproduce:
Create a closure that returns Void?, for example:
let action = UIAlertAction(title: title!, style: .Default) { (alert: UIAlertAction!) -> Void in
self.delegate?.myDelegateMethod?()
}
(A file with a complete example is attached.)
Expected Results:
I expect an implicit `return` to be inserted.
Alternatively, I expect an error like: “Return value of ‘Void?’ is not identical to closure return type ‘Void’”
Actual Results:
I get the error message “Could not find member 'Default’”
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!
Attachment: https://gist.github.com/getaaron/915e0af58cd2de4159dd