How can I avoid having the unchecked cast from `VM...
# android
g
How can I avoid having the unchecked cast from
VM
to
T
in this:
Copy code
inline fun <reified VM : ViewModel> FragmentActivity.viewModelProvider(crossinline provider: () -> VM) = lazy {
    val factory = object : ViewModelProvider.Factory {
        override fun <T : ViewModel> create(modelClass: Class<T>) =
                provider() as T
    }
    ViewModelProviders.of(this, factory).get(VM::class.java)
}
I would like to have VM and T be the same type