title: Hilt - inject classes as interfaces
body: <p>Lets say I have two interfaces and two classes that implements them.</p>
  <pre><code>interface ITest1 {
      fun doSomething()
  }
  
  interface ITest2 {
      fun doSomethingElse()
  }
  
  class Test1 @Inject constructor(): ITest1 {
  
      override fun doSomething() {
          println(&quot;Something&quot;)
      }
  }
      
  class Test2 @Inject constructor(): ITest2 {
  
      @Inject
      lateinit var test1: ITest1
  
      override fun doSomethingElse() {
          test1.doSomething()
          println(&quot;Something else &quot;)
      }
  }
  </code></pre>
  <p>I can make this work if I use @Bind:</p>
  <pre><code>@Module
  @InstallIn(SingletonComponent::class)
  internal abstract class DependenciesBindings {
      @Singleton
      @Binds
      abstract fun bindTest1(test1: Test1): ITest1
  
      @Singleton
      @Binds
      abstract fun bindTest2(test2: Test2): ITest2
  }
  </code></pre>
  <p>But I would like to do some configuration to classes before they are injected. To do so, I tried to use @Provide:</p>
  <pre><code>@Module(includes = [DependenciesBindings::class])
  @InstallIn(SingletonComponent::class)
  object Dependencies {
  
      @Singleton
      @Provides
      fun provideTest1(): Test1 {
          return Test1()
      }
  
      @Singleton
      @Provides
      fun provideTest2(): Test2 {
          return Test2()
      }
  }
  
  @Module
  @InstallIn(SingletonComponent::class)
  internal abstract class DependenciesBindings {
      @Singleton
      @Binds
      abstract fun bindTest1(test1: Test1): ITest1
  
      @Singleton
      @Binds
      abstract fun bindTest2(test2: Test2): ITest2
  }
  </code></pre>
  <p>But this crashes app:</p>
  <blockquote>
  <p>Caused by: kotlin.UninitializedPropertyAccessException: lateinit
  property test1 has not been initialized
  at Test2.getTest1(Test2.kt:8)
  at Test2.doSomethingElse(Test2.kt:11)</p>
  </blockquote>
  <p>Why this happens?</p>
  <p>I would expect ITest1 to be correctly injected as Test1 is provided and then bind to ITest1 interface.</p>
  <p>Is there a workaround to make this work?</p>