diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 291efc99d58..446c788a038 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -8428,6 +8428,328 @@ public inline fun > CharArray.associateTo(desti return destination } +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +public inline fun Array.associateWith(valueSelector: (K) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun ByteArray.associateWith(valueSelector: (Byte) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun ShortArray.associateWith(valueSelector: (Short) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun IntArray.associateWith(valueSelector: (Int) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun LongArray.associateWith(valueSelector: (Long) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun FloatArray.associateWith(valueSelector: (Float) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun DoubleArray.associateWith(valueSelector: (Double) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun BooleanArray.associateWith(valueSelector: (Boolean) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun CharArray.associateWith(valueSelector: (Char) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +public inline fun > Array.associateWithTo(destination: M, valueSelector: (K) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > ByteArray.associateWithTo(destination: M, valueSelector: (Byte) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > ShortArray.associateWithTo(destination: M, valueSelector: (Short) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > IntArray.associateWithTo(destination: M, valueSelector: (Int) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > LongArray.associateWithTo(destination: M, valueSelector: (Long) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > FloatArray.associateWithTo(destination: M, valueSelector: (Float) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > DoubleArray.associateWithTo(destination: M, valueSelector: (Double) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > BooleanArray.associateWithTo(destination: M, valueSelector: (Boolean) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > CharArray.associateWithTo(destination: M, valueSelector: (Char) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + /** * Appends all elements to the given [destination] collection. */ diff --git a/libraries/stdlib/common/src/generated/_UArrays.kt b/libraries/stdlib/common/src/generated/_UArrays.kt index f56b4612c27..9b48d88c280 100644 --- a/libraries/stdlib/common/src/generated/_UArrays.kt +++ b/libraries/stdlib/common/src/generated/_UArrays.kt @@ -3970,6 +3970,150 @@ public inline fun ShortArray.toUShortArray(): UShortArray { return UShortArray(this.copyOf()) } +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun UIntArray.associateWith(valueSelector: (UInt) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun ULongArray.associateWith(valueSelector: (ULong) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun UByteArray.associateWith(valueSelector: (UByte) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Returns a [Map] where keys are elements from the given array and values are + * produced by the [valueSelector] function applied to each element. + * + * If any two elements are equal, the last one gets added to the map. + * + * The returned map preserves the entry iteration order of the original array. + * + * @sample samples.collections.Collections.Transformations.associateWith + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun UShortArray.associateWith(valueSelector: (UShort) -> V): Map { + val result = LinkedHashMap() + return associateWithTo(result, valueSelector) +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > UIntArray.associateWithTo(destination: M, valueSelector: (UInt) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > ULongArray.associateWithTo(destination: M, valueSelector: (ULong) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > UByteArray.associateWithTo(destination: M, valueSelector: (UByte) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + +/** + * Populates and returns the [destination] mutable map with key-value pairs for each element of the given array, + * where key is the element itself and value is provided by the [valueSelector] function applied to that key. + * + * If any two elements are equal, the last one overwrites the former value in the map. + * + * @sample samples.collections.Collections.Transformations.associateWithTo + */ +@SinceKotlin("1.4") +@ExperimentalStdlibApi +@kotlin.internal.InlineOnly +public inline fun > UShortArray.associateWithTo(destination: M, valueSelector: (UShort) -> V): M { + for (element in this) { + destination.put(element, valueSelector(element)) + } + return destination +} + /** * Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original array. * diff --git a/libraries/stdlib/test/collections/ArraysTest.kt b/libraries/stdlib/test/collections/ArraysTest.kt index 797dba40d9c..09619196d09 100644 --- a/libraries/stdlib/test/collections/ArraysTest.kt +++ b/libraries/stdlib/test/collections/ArraysTest.kt @@ -1247,6 +1247,93 @@ class ArraysTest { } } + @Test fun associateWith() { + val items = arrayOf("Alice", "Bob", "Carol") + val itemsWithTheirLength = items.associateWith { it.length } + + assertEquals(mapOf("Alice" to 5, "Bob" to 3, "Carol" to 5), itemsWithTheirLength) + + val updatedLength = items.copyOfRange(1, 3) + .associateWithTo(itemsWithTheirLength.toMutableMap()) { name -> name.toLowerCase().count { it in "aeuio" } } + + assertEquals(mapOf("Alice" to 5, "Bob" to 1, "Carol" to 2), updatedLength) + } + + @Test fun associateWithPrimitives() { + assertEquals( + mapOf(1 to "1", 2 to "2", 3 to "3"), + intArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1.toByte() to "1", 2.toByte() to "2", 3.toByte() to "3"), + byteArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1.toShort() to "1", 2.toShort() to "2", 3.toShort() to "3"), + shortArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1L to "1", 2L to "2", 3L to "3"), + longArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1f to "1", 2f to "2", 3f to "3"), + floatArrayOf(1f, 2f, 3f).associateWith { if (it == 1f) "1" else if (it == 2f) "2" else "3" } + ) + assertEquals( + mapOf(1.0 to "1", 2.0 to "2", 3.0 to "3"), + doubleArrayOf(1.0, 2.0, 3.0).associateWith { if (it == 1.0) "1" else if (it == 2.0) "2" else "3" } + ) + assertEquals( + mapOf('1' to "1", '2' to "2", '3' to "3"), + charArrayOf('1', '2', '3').associateWith { it.toString() } + ) + assertEquals( + mapOf(false to "false", true to "true"), + booleanArrayOf(false, true).associateWith { it.toString() } + ) + } + + @Test fun associateWithToPrimitives() { + val expected = mapOf(1 to "one", 2 to "two", 3 to "three") + assertEquals( + mapOf(1 to "one", 2 to "2", 3 to "3"), + intArrayOf(2, 3).associateWithTo(expected.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1.toByte() to "one", 2.toByte() to "2", 3.toByte() to "3"), + byteArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toByte() }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1.toShort() to "one", 2.toShort() to "2", 3.toShort() to "3"), + shortArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toShort() }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1L to "one", 2L to "2", 3L to "3"), + longArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toLong() }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1f to "one", 2f to "2", 3f to "3"), + floatArrayOf(2f, 3f).associateWithTo(expected.mapKeys { it.key.toFloat() }.toMutableMap()) { + if (it == 1f) "1" else if (it == 2f) "2" else "3" + } + ) + assertEquals( + mapOf(1.0 to "one", 2.0 to "2", 3.0 to "3"), + doubleArrayOf(2.0, 3.0).associateWithTo(expected.mapKeys { it.key.toDouble() }.toMutableMap()) { + if (it == 1.0) "1" else if (it == 2.0) "2" else "3" + } + ) + assertEquals( + mapOf('1' to "one", '2' to "2", '3' to "3"), + charArrayOf('2', '3').associateWithTo(expected.mapKeys { '0' + it.key }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(false to "three", true to "true"), + booleanArrayOf(true, true).associateWithTo(expected.mapKeys { it.key % 2 == 0 }.toMutableMap()) { it.toString() } + ) + } + @Test fun reverseInPlace() { fun doTest(build: Iterable.() -> TArray, reverse: TArray.() -> Unit, snapshot: TArray.() -> List) { diff --git a/libraries/stdlib/test/collections/UnsignedArraysTest.kt b/libraries/stdlib/test/collections/UnsignedArraysTest.kt index d0874ca0002..846684ee7c0 100644 --- a/libraries/stdlib/test/collections/UnsignedArraysTest.kt +++ b/libraries/stdlib/test/collections/UnsignedArraysTest.kt @@ -723,6 +723,47 @@ class UnsignedArraysTest { } } + @Test + fun associateWithPrimitives() { + assertEquals( + mapOf(1u to "1", 2u to "2", 3u to "3"), + uintArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1.toUByte() to "1", 2.toUByte() to "2", 3.toUByte() to "3"), + ubyteArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1.toUShort() to "1", 2.toUShort() to "2", 3.toUShort() to "3"), + ushortArrayOf(1, 2, 3).associateWith { it.toString() } + ) + assertEquals( + mapOf(1UL to "1", 2UL to "2", 3UL to "3"), + ulongArrayOf(1, 2, 3).associateWith { it.toString() } + ) + } + + @Test + fun associateWithToPrimitives() { + val expected = mapOf(1u to "one", 2u to "two", 3u to "three") + assertEquals( + mapOf(1u to "one", 2u to "2", 3u to "3"), + uintArrayOf(2, 3).associateWithTo(expected.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1.toUByte() to "one", 2.toUByte() to "2", 3.toUByte() to "3"), + ubyteArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toUByte() }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1.toUShort() to "one", 2.toUShort() to "2", 3.toUShort() to "3"), + ushortArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toUShort() }.toMutableMap()) { it.toString() } + ) + assertEquals( + mapOf(1UL to "one", 2UL to "2", 3UL to "3"), + ulongArrayOf(2, 3).associateWithTo(expected.mapKeys { it.key.toULong() }.toMutableMap()) { it.toString() } + ) + } + @Test fun elementAt() { expect(0u) { ubyteArrayOf(0, 1, 2).elementAt(0) } diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index 9aa01a89ca9..a0dcbb081af 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -805,6 +805,8 @@ public final class kotlin/collections/ArraysKt { public static final fun associateTo ([Ljava/lang/Object;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map; public static final fun associateTo ([SLjava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map; public static final fun associateTo ([ZLjava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map; + public static final fun associateWith ([Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Ljava/util/Map; + public static final fun associateWithTo ([Ljava/lang/Object;Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map; public static final fun average ([B)D public static final fun average ([D)D public static final fun average ([F)D diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index a37c0ea9776..c2c12b0256b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -437,10 +437,15 @@ object Snapshots : TemplateGroupBase() { } val f_associateWith = fn("associateWith(valueSelector: (K) -> V)") { - include(Iterables, Sequences, CharSequences) + include(Iterables, Sequences, CharSequences, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) } builder { inline() + specialFor(ArraysOfPrimitives, ArraysOfUnsigned) { inlineOnly() } since("1.3") + specialFor(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) { + since("1.4") + annotation("@ExperimentalStdlibApi") + } typeParam("K", primary = true) typeParam("V") returns("Map") @@ -472,10 +477,15 @@ object Snapshots : TemplateGroupBase() { } val f_associateWithTo = fn("associateWithTo(destination: M, valueSelector: (K) -> V)") { - include(Iterables, Sequences, CharSequences) + include(Iterables, Sequences, CharSequences, ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) } builder { inline() + specialFor(ArraysOfPrimitives, ArraysOfUnsigned) { inlineOnly() } since("1.3") + specialFor(ArraysOfObjects, ArraysOfPrimitives, ArraysOfUnsigned) { + since("1.4") + annotation("@ExperimentalStdlibApi") + } typeParam("K", primary = true) typeParam("V") typeParam("M : MutableMap")