Why does this code fail at runtime, and what is the fix that preserves the intended threading?
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
fun numbers(): Flow<Int> = flow {
withContext(Dispatchers.IO) {
for (i in 1..3) emit(i)
}
}
fun main() = runBlocking {
numbers().collect { println(it) }
}