False positive compiler error when using closures
| Originator: | steve_w101 | ||
| Number: | rdar://17228969 | Date Originated: | 9-Jun-2014 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | 6.0 |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Certain code will fail to compile when used within closures.
Steps to Reproduce:
Create a .swift file with the following contents and try to compile:
protocol MyCustomProtocol {
func someDelegateMethod()
}
class MyCustomObject {
var delegate: MyCustomProtocol?;
func doSomethingAfterDelay() {
dispatch_after(2, dispatch_get_main_queue()) {
self.delegate?.someDelegateMethod()
}
}
}
Expected Results:
Successful compilation.
This can be worked around by replacing the disaptch_after with the following:
dispatch_after(2, dispatch_get_main_queue()) {
println("")
self.delegate?.someDelegateMethod()
}
i.e. adding println("") before the delegate call.
Actual Results:
Compiler error "Could not find member 'someDelegateMethod'"
Version:
Xcode 6.0 (6A215l)
OSX 10.9 13D65
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!