Prevent suspend lambda in inline function

Is there a way to prevent a suspend lambda from being passed to an inline function?

Consider example from the library:

public inline fun <K, V> MutableMap<K, V>.getOrPut(key: K, defaultValue: () -> V): V {
    val value = get(key)
    return if (value == null) {
        val answer = defaultValue()
        put(key, answer)
    } else {

The problem with this is it can create many bugs — if lambda is suspending. I am creating a similar function and would like to prevent the caller from passing a suspending lambda. Is there a way to get a compile-time error?

UPDATE: Looks like crossinline will do the trick?


Note that the operation is not guaranteed to be atomic if the map is being modified concurrently.

The missing modifier does not fix any issue, I suppose.

I am lucky that we run in a single thread, so it should be OK.