Hi, I'm running into this error when trying to use
async
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <T> CoroutineScope.async(context: CoroutineContext = ..., start: CoroutineStart = ..., block: suspend CoroutineScope.() → TypeVariable(T)): Deferred<TypeVariable(T)> defined in kotlinx.coroutines
I'm not sure how much I can pare down my example, because it seems pretty specific to what I'm trying to do. Here's essentially the function
suspend fun getTile(params: SomeType): GetTileResponse {
val cached = tileCache.get(params)
if (cached != null) {
return GetTileResponse.Available(cached)
}
val request = GetTileRequest(params)
val deferred = async {
makeRemoteRequest()
.map { convertIntoResponse(it) }
}
return GetTileResponse.Loading(deferred)
}
If I ask kotlin to generate an implementation of async, I get something which seems to look very similar to the definition of async (
https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html)
private fun async(block: suspend CoroutineScope.() -> Either<GetTileError, Bitmap>): Deferred<Either<GetTileError, Bitmap>> {
TODO("Not yet implemented")
}