More concise proper overloaded method selection


Let’s have 2 functions declaration

fun handle(param: Int, param2: Int, consumer: () -> Unit) {

fun handle(param: Int, param2: Int, consumer: (param: Int, param2: Int) -> Unit) {
    consumer(param, param2) 

And let’s try to call function using lambdas

handle(1, 2) {

Error, compiler can’t decide which function to call but it’s much more likely the first one, more - if I explicitly add empty arrow:

handle(1,2) { ->

IDE will highlight that arrow as not needed.

So I propose to use function without parameters when there are no references to “it” receiver when this situation appears.


I agree.

This is a extension of a topic discussed before (without solution)