Commits

Chris Lattner committed 4b8ccacf633
Fix <rdar://problem/22243469> QoI: Poor error message with throws, default arguments, & overloads and probably others. When we're type-checking a failed ApplyExpr that has an overload set that prevents getting a specific type to feed into the initial typechecking of the argument list, ranking can often narrow down the list of candidates further, to the point where there is only one candidate left or where all candidates agree that one argument is wrong. In this case, re-type-check the subexpr with the expected type. In the case of rdar://problem/22243469 we now produce: t.swift:6:11: error: invalid conversion from throwing function of type '() throws -> ()' to non-throwing function type '() -> Void' process { ^ instead of: t.swift:6:3: error: cannot invoke 'process' with an argument list of type '(() throws -> ())' process { ^ t.swift:6:3: note: overloads for 'process' exist with these partially matching parameter lists: (UInt, fn: () -> Void) process { ^ Which is a heck of a lot less specific. Similarly, in the testcase from rdar://23550816, instead of producing: takeTwoFuncsWithDefaults { $0 + 1 } error: cannot invoke 'takeTwoFuncsWithDefaults' with an argument list of type '((Int -> Int)?)' note: expected an argument list of type '(f1: (Int -> Int)?, f2: (String -> String)?)' we now produce: error: cannot convert value of type '_ -> Int' to expected argument type '(String -> String)?' which is a lot closer to what we want to complain about.