Make Map.toSortedMap accept Map out-projected by key type as the receiver.

Update related completion testData.
This commit is contained in:
Ilya Gorbunov
2016-05-17 19:28:30 +03:00
parent 9ff6a6260e
commit 738219d53e
2 changed files with 4 additions and 4 deletions
@@ -8,6 +8,6 @@ fun firstFun() {
}
// INVOCATION_COUNT: 1
// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"() for Map<K, V> in kotlin.collections" }
// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"(comparator: Comparator<in Int>) for Map<K, V> in kotlin.collections" }
// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"() for Map<out K, V> in kotlin.collections" }
// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"(comparator: Comparator<in Int>) for Map<out K, V> in kotlin.collections" }
// NOTHING_ELSE
@@ -41,7 +41,7 @@ public inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -
*
* @sample test.collections.MapJVMTest.toSortedMap
*/
public fun <K : Comparable<K>, V> Map<K, V>.toSortedMap(): SortedMap<K, V> = TreeMap(this)
public fun <K : Comparable<K>, V> Map<out K, V>.toSortedMap(): SortedMap<K, V> = TreeMap(this)
/**
* Converts this [Map] to a [SortedMap] using the given [comparator] so that iteration order will be in the order
@@ -49,7 +49,7 @@ public fun <K : Comparable<K>, V> Map<K, V>.toSortedMap(): SortedMap<K, V> = Tre
*
* @sample test.collections.MapJVMTest.toSortedMapWithComparator
*/
public fun <K, V> Map<K, V>.toSortedMap(comparator: Comparator<in K>): SortedMap<K, V>
public fun <K, V> Map<out K, V>.toSortedMap(comparator: Comparator<in K>): SortedMap<K, V>
= TreeMap<K, V>(comparator).apply { putAll(this@toSortedMap) }
/**