Make Map.toSortedMap accept Map out-projected by key type as the receiver.
Update related completion testData.
This commit is contained in:
@@ -8,6 +8,6 @@ fun firstFun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// INVOCATION_COUNT: 1
|
// INVOCATION_COUNT: 1
|
||||||
// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"() 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<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
|
// NOTHING_ELSE
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public inline fun <K, V> ConcurrentMap<K, V>.getOrPut(key: K, defaultValue: () -
|
|||||||
*
|
*
|
||||||
* @sample test.collections.MapJVMTest.toSortedMap
|
* @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
|
* 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
|
* @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) }
|
= TreeMap<K, V>(comparator).apply { putAll(this@toSortedMap) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user