Hack: do not add trivial constraints (t <: Any?) for constituent types,

otherwise nested calls handling logic in old inference wouldn't work for type alias constructors.
This commit is contained in:
Dmitry Petrov
2016-11-10 12:23:25 +03:00
parent 549ae59562
commit 37eedc3703
7 changed files with 114 additions and 1 deletions
@@ -0,0 +1,20 @@
import kotlin.test.*
import java.util.*
typealias HM<Kt, Vt> = HashMap<Kt, Vt>
fun <K, V, M : MutableMap<in K, MutableList<V>>> updateMap(map: M, k: K, v: V): M {
map[k]!!.add(v)
return map
}
val nameToTeam = listOf("Alice" to "Marketing", "Bob" to "Sales", "Carol" to "Marketing")
val namesByTeam = nameToTeam.groupBy({ it.second }, { it.first })
val mutableNamesByTeam1 = updateMap(HM(), "", "")
val mutableNamesByTeam2 = updateMap(HashMap(), "", "")
fun test() {
assertEquals(namesByTeam, mutableNamesByTeam1)
assertEquals(namesByTeam, mutableNamesByTeam2)
}
@@ -0,0 +1,9 @@
package
public val mutableNamesByTeam1: java.util.HashMap<kotlin.String, kotlin.collections.MutableList<kotlin.String>>
public val mutableNamesByTeam2: java.util.HashMap<kotlin.String, kotlin.collections.MutableList<kotlin.String>>
public val nameToTeam: kotlin.collections.List<kotlin.Pair<kotlin.String, kotlin.String>>
public val namesByTeam: kotlin.collections.Map<kotlin.String, kotlin.collections.List<kotlin.String>>
public fun test(): kotlin.Unit
public fun </*0*/ K, /*1*/ V, /*2*/ M : kotlin.collections.MutableMap<in K, kotlin.collections.MutableList<V>>> updateMap(/*0*/ map: M, /*1*/ k: K, /*2*/ v: V): M
public typealias HM</*0*/ Kt, /*1*/ Vt> = java.util.HashMap<Kt, Vt>