в моем приложении для Android
import kotlinx.coroutines.*
import retrofit2.Response
import java.util.*
fun executeTraderOperation(traderOperation: Trader.Operation, base: String, quote: String): Response<Void> {
lateinit var executeOperations: Response<Void>
GlobalScope.launch(Dispatchers.IO) {
executeOperations = async { runOperation(traderOperation, base, quote) }
}
return executeOperations
}
suspend fun runOperation(traderOperation: Trader.Operation, base: String, quote: String): Response<Void> {
val traderMonitorRestClient = RestClientFactory.createRestClient(TraderMonitorRestClient::class.java)
val sender = BuildConfig.APPLICATION_ID + "_" + BuildConfig.VERSION_NAME
val key = DateUtil.getDateAsString(Date(), "mmHHddMMyyyy")
val executeTraderOperation = traderMonitorRestClient.executeTraderOperation(traderOperation.toString().toLowerCase(), base.trim(), quote.trim(), sender, key)
val response = executeTraderOperation.await()
return response
}
Но я получаю ошибку компиляции в этой строке:
executeOperations = async { runOperation(traderOperation, base, quote) }
сообщение об ошибке:
Type inference failed. Expected type mismatch:
required:
Response<Void>
found:
Deferred<Response<Void>>