Repository: square/anvil
Issue: Anvil drops covariance hint for assisted injection factories

```kotlin
class MonitorWaiter @AssistedInject constructor(
  @Main private val mainScheduler: Scheduler,
  @Assisted private val waitForMonitor: Observable<Class<out SellerScreenMonitor>>,
  @Assisted private val currentMonitor: Observable<SellerScreenMonitor>,
  @Assisted private val getCurrentMonitor: () -> SellerScreenMonitor
) {
  @AssistedFactory
  interface Factory {
    fun create(
      waitForMonitor: Observable<Class<out SellerScreenMonitor>>,
      currentMonitor: Observable<SellerScreenMonitor>,
      getCurrentMonitor: () -> SellerScreenMonitor
    ): MonitorWaiter
  }
}
```
This will fail with Anvil, but be successful with Kapt. 

Changed files:
compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt
compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt

diff --git a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt
index ecd2b95..10bcddb 100644
--- a/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt
+++ b/compiler-utils/src/main/java/com/squareup/anvil/compiler/internal/KotlinPoetUtils.kt
@@ -56,6 +56,9 @@ import org.jetbrains.kotlin.resolve.constants.KClassValue
 import org.jetbrains.kotlin.resolve.descriptorUtil.parents
 import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
 import org.jetbrains.kotlin.types.KotlinType
+import org.jetbrains.kotlin.types.Variance.INVARIANT
+import org.jetbrains.kotlin.types.Variance.IN_VARIANCE
+import org.jetbrains.kotlin.types.Variance.OUT_VARIANCE
 import org.jetbrains.kotlin.types.typeUtil.isTypeParameter
 import org.jetbrains.kotlin.utils.addToStdlib.safeAs
 import java.io.ByteArrayOutputStream
@@ -255,7 +258,12 @@ public fun KotlinType.asTypeNameOrNull(
     if (typeProjection.isStarProjection) {
       STAR
     } else {
-      typeProjection.type.asTypeName()
+      val typeName = typeProjection.type.asTypeName()
+      when (typeProjection.projectionKind) {
+        INVARIANT -> typeName
+        OUT_VARIANCE -> WildcardTypeName.producerOf(typeName)
+        IN_VARIANCE -> WildcardTypeName.consumerOf(typeName)
+      }
     }
   }
 
diff --git a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt
index d3d018f..bed12b0 100644
--- a/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt
+++ b/compiler/src/test/java/com/squareup/anvil/compiler/dagger/AssistedFactoryGeneratorTest.kt
@@ -1438,6 +1438,70 @@ public final class AssistedServiceFactory_Impl implements AssistedServiceFactory
     }
   }
 
+  @Test fun `assisted covariant parameters are supported`() {
+    compile(
+      """
+      package com.squareup.test
+      
+      import dagger.assisted.Assisted
+      import dagger.assisted.AssistedFactory
+      import dagger.assisted.AssistedInject
+      import dagger.Module
+      import dagger.Provides
+      import java.lang.Class
+      import javax.inject.Provider
+      
+      data class AssistedService @AssistedInject constructor(
+        @Assisted private val list: List<Class<out String>>,
+        private val int: Int
+      ) {
+        override fun equals(other: Any?): Boolean {
+          if (this === other) return true
+          if (javaClass != other?.javaClass) return false
+    
+          other as AssistedService
+    
+          if (list.size != other.list.size) return false
+          if (int != other.int) return false
+    
+          return true
+        }
+    
+        override fun hashCode(): Int {
+          var result = int
+          result = 31 * result + list.hashCode()
+          return result
+        }
+      }
+      
+      @AssistedFactory
+      interface AssistedServiceFactory {
+        fun create(list: List<Class<out String>>): AssistedService
+      }
+      """
+    ) {
+      val factoryImplClass = assistedServiceFactory.implClass()
+      val generatedFactoryInstance = assistedService.factoryClass()
+        .createInstance(Provider { 5 })
+      val factoryImplInstance = factoryImplClass.createInstance(generatedFactoryInstance)
+
+      val staticMethods = factoryImplClass.declaredMethods.filter { it.isStatic }
+      assertThat(staticMethods).hasSize(1)
+
+      val factoryProvider = staticMethods.single { it.name == "create" }
+        .invoke(null, generatedFactoryInstance) as Provider<*>
+      assertThat(factoryProvider.get()::class.java).isEqualTo(factoryImplClass)
+
+      val assistedServiceInstance = factoryImplClass.declaredMethods
+        .filterNot { it.isStatic }
+        .single { it.name == "create" }
+        .invoke(factoryImplInstance, listOf<Class<out String>>())
+
+      assertThat(assistedServiceInstance)
+        .isEqualTo(assistedService.createInstance(listOf<Class<out String>>(), 5))
+    }
+  }
+
   @Suppress("CHANGING_ARGUMENTS_EXECUTION_ORDER_FOR_NAMED_VARARGS")
   private fun compile(
     vararg sources: String,