2) Is it a compiler bug that suspending function r...
# coroutines
u
2) Is it a compiler bug that suspending function references are no longer accepted if I remove the suspend modifier?
d
Example?
u
Copy code
class X {

    suspend fun suspending() {}

    suspend fun test1() {
        // Error goes away if we add suspend modifier to logError an it's parameter block
        // But then IDE complains about redundant suspend modifier
        logError(::suspending)
    }

    suspend fun test2() {
        logError { suspending() }
    }

    inline fun logError(block: () -> Unit) {
        try {
            block()
        } catch (e: Exception) {
            //Log Exception
        }
    }
}
v
It is both bug in the compiler and in the inspection 🙂 https://youtrack.jetbrains.com/issue/KT-30536
u
@Vsevolod Tolstopyatov [JB] thanks for opening the ticket and especially for pointing out the name of the inspection 🙂
And now I get a
wrong bytecode generated
error for this:
Copy code
class X {

    suspend fun suspending() {}

    suspend fun test() {
        logError(::suspending)
    }

    suspend inline fun runBlock(block: suspend () -> Unit) {
        logError(block)
    }

    suspend inline fun logError(block: suspend () -> Unit) {
        try {
            block()
        } catch (e: Exception) {
            //Log Exception
        }
    }
}
i
@uli Can you, please, open a separate ticket for this case? I'll take a look.
u