Android Studio/IntelliJ async replacement is not context aware?


#1

Hello, I’m currently developing an app in Android Studio and to login the user I use the function loginUser (belonging to an Activity View Model)

Given that I need to do an Network/IO call, I use Dispatchers.IO as demo’d bellow

private val job = Job()

override val coroutineContext: CoroutineContext
    get() = Dispatchers.IO + job

However, Android Studio tells me the call is replaceable with withContext(Dispatchers.Default), which it shouldn’t be given the need of the IO dispatcher, right?

suspend fun loginUser(user: User): Response {
    return async {
        Network.loginUser(user)
    }.await()
}

EDIT: If I do the following, there’s no warning

suspend fun loginUser(user: User): Response {
    return async {
        return@async Network.loginUser(user)
    }.await()
}

This way I ask if I’m missing something or I am right and this is just a bug on the checker.
Thank you!