Open
Description
Issue to be solved
Generic functions which have a type parameter that is not used in an argument, but is used in a return type, should have their type argument inferred when an expected type is given.
For example, given a generic function
fun foo<T>() -> T { /* ... */ }
Then an invocation with an expected type should succeed, inferring the type parameter T
to Bool
:
let x: Bool = foo()
However, in an invocation without an expected type, the type argument cannot be inferred and an explicit type argument is necessary:
let x = foo<Bool>()
Suggested Solution
If an expected type is provided for an invocation, infer the type arguments based on the return type (if any).