Overload resolution ambiguity with suspend

I have the following code:

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

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

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?


One possible solution is

    test(suspend {

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.