This is not possible, because the method you are rewriting ( TypeFactory.create) does not have an upper bound (which translates <T : Any>to Kotlin). There is create Tno guarantee in your method Enum<T>(therefore, it cannot be passed as an argument to your adapter).
, , , factory ( factory , ).
class SmartEnumTypeAdapterFactory(fallbackKey: String) : TypeAdapterFactory {
private val fallbackKey = fallbackKey.toLowerCase(Locale.US)
override fun <T> create(gson: Gson?, type: TypeToken<T>): TypeAdapter<T>? {
val rawType = type.rawType
return if (!rawType.isEnum) null else SmartEnumTypeAdapter(rawType)
}
private class SmartEnumTypeAdapter<T>(classOfT: Class<in T>) : TypeAdapter<T>() {
override fun write(out: JsonWriter?, value: T) {
TODO("not implemented")
}
override fun read(`in`: JsonReader?): T {
TODO("not implemented")
}
}
}
(classOfT Class<in T>, TypeToken.rawType() a Class<? super T>)