title: Binding Into Map With KClass Type
body: <p>I am trying to bind subclasses of <code>ViewModel</code> into a map by their <code>KClass</code> types:</p>
  
  <pre><code>@Module abstract class ViewModelModule {
  
      @Binds @IntoMap @ViewModelKey(MyViewModel::class)
      abstract fun bindsMyViewModel(viewModel: MyViewModel): ViewModel
  
      @Binds abstract fun bindViewModelFactory(factory: ViewModelFactory): ViewModelProvider.Factory
  
  }
  </code></pre>
  
  <p>But I am getting Dagger compiler error:</p>
  
  <pre><code>e: ~/Example/app/build/tmp/kapt3/stubs/debug/com/example/app/injection/AppComponent.java:5: error: [dagger.android.AndroidInjector.inject(T)] java.util.Map&lt;kotlin.reflect.KClass&lt;? extends android.arch.lifecycle.ViewModel&gt;,? extends javax.inject.Provider&lt;android.arch.lifecycle.ViewModel&gt;&gt; cannot be provided without an @Provides-annotated method.
  e: 
  
  e: public abstract interface AppComponent {
  e:                 ^
  e:       java.util.Map&lt;kotlin.reflect.KClass&lt;? extends android.arch.lifecycle.ViewModel&gt;,? extends javax.inject.Provider&lt;android.arch.lifecycle.ViewModel&gt;&gt; is injected at
  e:           com.example.app.ui.ViewModelFactory.&lt;init&gt;(creators)
  e:       com.example.app.ui.ViewModelFactory is injected at
  e:           com.example.app.injection.ViewModelModule.bindViewModelFactory(p0)
  e:       android.arch.lifecycle.ViewModelProvider.Factory is injected at
  e:           com.example.app.ui.MyFragment.setViewModelFactory(p0)
  e:       com.example.app.ui.MyFragment is injected at
  e:           dagger.android.AndroidInjector.inject(arg0)
  </code></pre>
  
  <p>The above <code>ViewModelModule</code> is included in my <code>AppModule</code>, which is a module in my <code>AppComponent</code>. So Dagger should be able to provide the <code>Map&lt;KClass&lt;out ViewModel&gt;, Provider&lt;ViewModel&gt;&gt;</code> required by my <code>ViewModelFactory</code>, but I cannot figure out why it is crashing.</p>
  
  <hr>
  
  <p>I also tried switching the <code>ViewModelKey</code> annotation class over to Java, taking a <code>Class</code> as a constructor parameter instead of a <code>KClass</code>. Then modified my <code>ViewModelFactory</code> to depend on a <code>Map&lt;Class&lt;out ViewModel&gt;, Provider&lt;ViewModel&gt;&gt;</code>, but the same error occurred.</p>