TF-232 [Sema] Improve @dynamicCallable diagnostics for calls with incorrect parameter types
Issue Description:
If you call a dynamicCallable type as a function with the wrong type of parameters, it gives the message "Cannot call value of non-function type 'Foo'". The error message should be more akin to the message when you call a regular function with incorrect parameter types: "Cannot convert value of type 'String' to expected argument type 'Int'".
@dynamicCallablestructFoo {
funcdynamicallyCall(withArgumentsargs: [Int]) -> Int {
returnargs.count
}
}
letfoo = Foo()
letc: Int = foo(1, 2, 3) // okletd = foo("abc") // Cannot call value of non-function type 'Foo'// this error message is okay:lete: String = foo(1, 2, 3) // Cannot convert value of type 'Int' to specified type 'String'
The text was updated successfully, but these errors were encountered:
@dynamicCallable currently only has bare-bones diagnostics (see here). FailureDiagnosis::visitApplyExpr has a lot of machinery for producing good diagnostics for regular ApplyExprs though, one idea is to make use of that machinery for @dynamicCallable.
Environment
Toolchain: swift-5.0-DEVELOPMENT-SNAPSHOT-2018-12-28-a
Additional Detail from JIRA
md5: 93063d6e18bb5003b95809d72d784923
cloned to:
Issue Description:
If you call a dynamicCallable type as a function with the wrong type of parameters, it gives the message "Cannot call value of non-function type 'Foo'". The error message should be more akin to the message when you call a regular function with incorrect parameter types: "Cannot convert value of type 'String' to expected argument type 'Int'".
The text was updated successfully, but these errors were encountered: