KT.SUSPEND_FUN_WITH_COROUTINE_SCOPE_RECEIVER
Functions that use CoroutineScope as receive are marked as suspend
Suspend functions that use CoroutineScope as receiver should not be marked as suspend. A CoroutineScope provides structured concurrency via its coroutineContext. A suspend function also has its own coroutineContext, which is now ambiguous and mixed with the receiver`s.
Noncompliant Code
Copy
suspend fun CoroutineScope.foo() {
launch {
delay(1.seconds)
}
}
Compliant Code
Copy
fun CoroutineScope.foo() {
launch {
delay(1.seconds)
}
}
// Alternative
suspend fun foo() = coroutineScope {
launch {
delay(1.seconds)
}
}