【发布时间】:2021-09-27 14:07:31
【问题描述】:
我正在迁移旧的 Android 代码库。我收到上述代码的以下错误。问题的原因可能是什么?怎样才能轻松解决?
fun action(action: FunAction) = actor.offer(action)
private val actor = actor<FunAction>(Dispatchers.Main, Channel.CONFLATED) {
for (action in this) when (action) {
is FunAction.Init -> { }
is FunAction.SaveUserSetting -> { }
is FunAction.UploadProfilePhoto -> { }
}
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun <E> CoroutineScope.actor(context: CoroutineContext = ..., capacity: Int = ...,
start: CoroutineStart = ..., onCompletion: CompletionHandler? /* = ((cause: Throwable?) -> Unit)? */ = ...,
block: suspend ActorScope<TypeVariable(E)>.() -> Unit): SendChannel<TypeVariable(E)>
defined in kotlinx.coroutines.channels
【问题讨论】:
标签: android kotlin kotlin-coroutines coroutine