k
doesnt work
s
Can you show your example and what not working? It is working for me...
k
k, wait a bit - will compile
s
every invocation should generate anonymous class
Copy code
abstract class TypeToken<T>

inline fun <reified T> typeOf(): Type? {
  val token = object : TypeToken<T>() {}
  return (token.javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0]
}

fun main(args: Array<String>) {
  println(typeOf<Int>())
  println(typeOf<List<Int>>())
}
prints
Copy code
class java.lang.Integer
java.util.List<? extends java.lang.Integer>
k
does it works with gson?
s
yes
k
hm...
seems like u'r righht... but i belive i already try such way and it wasnt work... smth was diffrent
nah
it is not xD
same error
look
inline fun <reified T> typeToken() = object : TypeToken<ApiResponse<T>>() {}
fun getCities() = request(typeToken<ArrayList<CityInfo>>(), "catalogue.Cities")
private fun <T> request(outType: TypeToken<ApiResponse<T>>, method: String, token: String? = null, vararg params: Pair<String, Any>): Call<T>? {
****model.ApiResponse<T>
k
close - unfortunatly not the stuff i need - i need to parse and genertate type of, main problem is - clases not generated by that fun
so only way is raw one
thats why define might be better - smth like preprocessor
anyway ty for try