I have a class Runner that implements the CoroutineScope interface as shown below. It has a suspended function called run. when I use the co-routine builder functions (launch, async) in this suspended run function I get the below warning
Ambiguous coroutineContext due to CoroutineScope receiver of suspend function
The Runner class has a single coroutineContext property implemented. Can someone explain the logic behind the warning message?
class Runner: CoroutineScope {
override private val coroutineContext = Dispatchers.IO
suspend fun run() {
val job1 = launch { delay(2000); println("launching job1") }
val job2 = launch { delay(2000); println("launching job2") }
listOf(job1, job2).forEach { it.join() }
}
}