Swift: inaccurate(?) "could not find an overload" error

Originator:garth
Number:rdar://19720849 Date Originated:04-Feb-2015 02:23 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 6.2b5 6C121
Classification:Other Bug Reproducible:Always
 
The code below yields the error shown. I accept that the call might be ambiguous or even might yield the unexpected result of a Test instance. However, the actual error message complains of being unable to find any valid interpretation, which seems wrong. The supplied expression should either be a Double or a Test, both of which have abs() defined. Nu?

protocol TestConvertible {
    func toTest() -> Test
}

class Test: TestConvertible {
    func toTest() -> Test { return self }
}

extension Double: TestConvertible {
    func toTest() -> Test { return Test() }
}

func abs(x: Test) -> Test {
    return Test()
}

func -<T: TestConvertible, U: TestConvertible>(lhs: T, rhs: U) -> Test {
    return Test()
}

let aNumber = 23.4 - 3.1415     // aNumber is Double
let abs1 = abs(aNumber)         // Fine, 20.26
let abs2 = abs(23.4 - 3.1415)   // Error: could not find an overload for 'abs'
                                //   that accepts the supplied arguments

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!