title: Implementing TypeAdapterFactory with TypeAdapter in Kotlin
body: <p>I'm trying implement some particular GSON TypeAdapter in Kotlin language for my android project.</p>
  
  <p>The issue I'm facing is compile error with inability to infer type: <code>Type inference failed: 'T' cannot capture 'in (T..T?'. Type parameter has an upper bound 'Enum&lt;T&gt;' that cannot be satisfied capturing 'in' projection</code></p>
  
  <p>The code is following:</p>
  
  <pre><code>  class SmartEnumTypeAdapterFactory(fallbackKey: String) : TypeAdapterFactory {
  
       private val fallbackKey = fallbackKey.toLowerCase(Locale.US)
  
       override fun &lt;T : Any&gt; create(gson: Gson?, type: TypeToken&lt;T&gt;): TypeAdapter&lt;T&gt;? {
          val rawType = type.rawType
          return if (!rawType.isEnum) null else SmartEnumTypeAdapter(rawType)
       }
  
       class SmartEnumTypeAdapter&lt;T : Enum&lt;T&gt;&gt;(classOfT: Class&lt;T&gt;) : TypeAdapter&lt;T&gt;() {
  
          override fun write(out: JsonWriter?, value: T) {
             TODO("not implemented")
          }
  
          override fun read(`in`: JsonReader?): T {
             TODO("not implemented")
          }
       }
    }
  </code></pre>
  
  <p>The reason I want to have <code>classOfT: Class&lt;T&gt;</code> as parameter for TypeAdapter is out of context of this problem.</p>