Overload resolution ambiguity with suspend

Hello,
I have the following code:

	suspend fun test(f: suspend () -> Unit) {
		f()
	}

	fun test(f: () -> Unit) {
		f()
	}
	
	fun main() {
		// Compile error below!
		test {
			delay(1000)
		}
	}

Unfortunately, this does not compile. The compiler is not able to deduce that the lambda must be suspendable, because it calls a suspending function.

In my case, I can’t have a single inline function, because of technical reasons that prevent inlining.

Is it possible to support this by the compiler?

Thanks

One possible solution is

    test(suspend {
        delay(1000)
    })

That only allows the suspend version to be called. The non suspend method can not be called still.

If you explained the reason you can’t inline, someone might be able to find a workaround.

Otherwise, different names may just be necessary unless you want to force callers to use some awkward work around like assigning their lambda to a variable before calling.

The main block does not create a coroutine context so calling the suspend version of test is invalid at this point.