OverloadResolutionByLambdaReturnType
Enables overload selection based on the type of the value returned from lambda argument.
When two or more function overloads have otherwise the same parameter lists that differ only in the return type of a functional parameter, this annotation enables overload selection by the type of the value returned from the lambda function passed to this functional parameter.
Example:
@OverloadResolutionByLambdaReturnType
fun create(intProducer: () -> Int): Int
fun create(doubleProducer: () -> Double): Double
val newValue = create { 3.14 }
The annotation being applied to one of overloads allows to resolve this ambiguity by analyzing what value is returned from the lambda function.
This annotation is also used to discriminate the annotated overloads in case if overload selection still cannot choose one of them even taking in account the result of lambda parameter analysis. In that case a warning is reported.
Note: this annotation is experimental, see ExperimentalTypeInference on how to opt-in for it.