Xcode-6.3-Beta (6D520o): Unable to overload function on a closure parameter that has an optional obejct parameter
| Originator: | segiddins | ||
| Number: | rdar://19850344 | Date Originated: | 16-Feb-2015 12:55 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode-6.3-Beta (6D520o) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
In Swift, you can correctly overload a function based upon the type signature of a closure parameter, but that doesn’t work when the parameter is an object.
Steps to Reproduce:
Attempt to compile the following code:
class Realm {
func f(block: (() -> Void)) {
block()
}
func f(block: ((Realm) -> Void)) {
block(self)
}
}
Realm().f {
println("no args")
}
Realm().f { realm in
println("realm: \(realm)")
}
Expected Results:
The code compiles
Actual Results:
At the second invocation of Realm().f, there’s an “Ambiguous use of ‘f’” compiler error
Regression:
N/A
Notes:
This overloading works if the second definition of f were as follows:
func f(block: ((Int) -> Void)) {
block(0)
}
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!