Anyway I can make this work somehow ? ``` fun &lt...
# announcements
m
Anyway I can make this work somehow ?
Copy code
fun <T> foo(aClass: java.lang.Class<T>): MutableList<T> {
  return mutableListOf()
}

inline fun <reified T:Any> bar(t: T): MutableList<T> {
  // fails here: expected: MutableList<T>, found: MutableList<out T>
  return foo(t::class.java) 
}
k
Not really, it just doesn't make sense:
t
could have a subtype of
T
, and so
t::class.java
could be a subclass of
Class<T>
and a
MutableList
is invariant. The only thing you can do is make
bar
return
MutableList<out T>
which is correct.
m
t
could have a subtype of
T
right, thanks !