Re-posting here for visibility: > Kotlin shoul...
# language-proposals
b
Re-posting here for visibility:
Kotlin should automatically choose lambda expressions with a single argument over multiple arguments for the implicit case. You should not need to specify an explicit lambda signature in order to use
it
when competing overloads all have higher arity.
https://github.com/kotlintest/kotlintest/pull/506#issuecomment-451624300
a
What if there is an overload with a no-argument function type?
b
It is possible to disambiguate if the lambda references
it
, otherwise the language should prefer to use the function type with the fewest arguments.
i
Lambdas can be nested deep into each other, so to find out whether
it
is used, the compiler would have to analyze a lot of code. And analyzing lambda bodies before completing overload resolution can hit exponential complexity in case of nested lambdas.
b
A good compromise would be to always choose the lowest arity (either nullary or unary) lambda that applies in a given context when lambda arguments are absent
a
Right now its impossible to call a 0-argument lambda if there are overloads with lambdas that have arguments