Repository: evant/kotlin-inject (kotlin)

Issue:
Multi-bindings does not work with type aliases
Suppose I have a component such as:
```kotlin
@Component
abstract class MyComponent {
  @Provides @IntoSet fun integer(): Int = 1
  @Provides @IntoSet fun myNumber(): MyNumber = 2

  abstract val integerSet: Set<Int>
  abstract val myNumberSet: Set<MyNumber>
}
```

Executing the following
```kotlin
with(MyComponent::class.create()) {
  println("Contents of integer set: $integerSet")
  println("Contents of myNumber set: $myNumberSet")
}
```

prints
```
Contents of integer set: [1]
Contents of myNumber set: [1]
```

Ideally `typealias` would allow generating another multibindings on the graph. 

Use case: Having different set of Interceptors for OkHttp (regular and Network types).

Pull request description:
Fixes #240

Patch:
diff --git a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt
index 05600def..48fe6c68 100644
--- a/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt
+++ b/kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt
@@ -245,7 +245,7 @@ class TypeResultResolver(private val provider: AstProvider, private val options:
     }
 
     private fun Context.set(key: TypeKey): TypeResult? {
-        val innerType = key.type.arguments[0].resolvedType()
+        val innerType = key.type.arguments[0]
         if (innerType.isFunction()) {
             val containerKey = ContainerKey.SetKey(innerType.arguments.last(), key.qualifier)
             val args = types.containerArgs(containerKey)


Test patch:
diff --git a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
index d19abaa5..b26cb9c0 100644
--- a/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
+++ b/integration-tests/common/src/test/kotlin/me/tatarka/inject/test/MultibindsTest.kt
@@ -98,6 +98,38 @@ abstract class AssistedSetComponent {
     fun fooValue2(@Assisted arg: String): FooValue = FooValue("${arg}2")
 }
 
+typealias MyString = String
+
+@Component
+abstract class TypeAliasSetComponent {
+    abstract val stringItems: Set<String>
+
+    abstract val myStringItems: Set<MyString>
+
+    @Provides
+    @IntoSet
+    fun stringValue1(): String = "string"
+
+    @Provides
+    @IntoSet
+    fun stringValue2(): MyString = "myString"
+}
+
+@Component
+abstract class TypeAliasKeyMapComponent {
+    abstract val stringMap: Map<String, String>
+
+    abstract val myStringMap: Map<MyString, String>
+
+    @Provides
+    @IntoMap
+    fun stringEntry1(): Pair<String, String> = "1" to "string"
+
+    @Provides
+    @IntoMap
+    fun myStringEntry1(): Pair<MyString, String> = "1" to "myString"
+}
+
 class MultibindsTest {
 
     @Test
@@ -148,4 +180,20 @@ class MultibindsTest {
             FooValue("arg1"), FooValue("arg2")
         )
     }
+
+    @Test
+    fun generates_a_component_with_different_sets_for_different_typealias() {
+        val component = TypeAliasSetComponent::class.create()
+
+        assertThat(component.stringItems).containsOnly("string")
+        assertThat(component.myStringItems).containsOnly("myString")
+    }
+
+    @Test
+    fun generates_a_component_with_different_maps_for_different_key_typealias() {
+        val component = TypeAliasKeyMapComponent::class.create()
+
+        assertThat(component.stringMap).containsOnly("1" to "string")
+        assertThat(component.myStringMap).containsOnly("1" to "myString")
+    }
 }
\ No newline at end of file