Xcode-beta (7A152u): Rethrowing Functions in Swift Should Detect Whether Inline Closures Throw
| Originator: | john | ||
| Number: | rdar://21786038 | Date Originated: | 12-Jul-2015 02:01 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-beta (7A152u) |
| Classification: | Enhancement | Reproducible: | Always |
Summary: When calling a rethrowing function with an inline closure, it always assumes that the closure can throw. Steps to Reproduce: 1. Create a method that takes in a closure and rethrows any errors from that closure. 2. Call that method with a simple inline closure that does not throw any errors. Expected Results: The code should compile and not require any error handling. Actual Results: The compiler requires that the call to the rethrowing method be enclosed in a do-catch block, or that the impossible errors be handled in some other way. Regression: Notes: This only seems to affect inline closures. If you take the same closure code and store it in a local variable, and then pass that variable to the rethrowing function, it correctly determines that the call cannot throw. I’ve attached a project that demonstrates the issue.
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!