Inspectopedia Help

Ambiguous coroutineContext due to CoroutineScope receiver of suspend function

Reports calls and accesses of CoroutineScope extensions or members inside suspend functions with CoroutineScope receiver.

When a function is suspend and has CoroutineScope receiver, it has ambiguous access to CoroutineContext via kotlin.coroutines.coroutineContext and via CoroutineScope.coroutineContext, and two these contexts are different in general.

To improve this situation, one can wrap suspicious call inside coroutineScope { ... } or get rid of CoroutineScope function receiver.

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023