diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/collections/CollectionsNative.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/collections/CollectionsNative.kt new file mode 100644 index 00000000000..3af4c80e730 --- /dev/null +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/collections/CollectionsNative.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.collections + +import kotlin.experimental.ExperimentalNativeApi + +/** + * Replaces each element in the list with a result of a transformation specified. + */ +// Deprecate in favour of KT-57152 when it's provided. +@ExperimentalNativeApi +public fun MutableList.replaceAll(transformation: (T) -> T) { + val it = listIterator() + while (it.hasNext()) { + val element = it.next() + it.set(transformation(element)) + } +} \ No newline at end of file diff --git a/libraries/stdlib/native-wasm/src/kotlin/collections/Collections.kt b/libraries/stdlib/native-wasm/src/kotlin/collections/Collections.kt index 520dc1040e6..3333aba2421 100644 --- a/libraries/stdlib/native-wasm/src/kotlin/collections/Collections.kt +++ b/libraries/stdlib/native-wasm/src/kotlin/collections/Collections.kt @@ -56,17 +56,6 @@ internal actual inline fun buildListInternal(capacity: Int, builderAction: M } -/** - * Replaces each element in the list with a result of a transformation specified. - */ -public fun MutableList.replaceAll(transformation: (T) -> T) { - val it = listIterator() - while (it.hasNext()) { - val element = it.next() - it.set(transformation(element)) - } -} - /** * Groups elements from the [Grouping] source by key and counts elements in each group. * diff --git a/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/JointSet.kt b/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/JointSet.kt index 74384a4f21d..fce62bfe7c6 100644 --- a/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/JointSet.kt +++ b/libraries/stdlib/native-wasm/src/kotlin/text/regex/sets/JointSet.kt @@ -79,6 +79,7 @@ open internal class JointSet(children: List, fSet: FSet) : Abstract assert(newFSet == fSet) } + @OptIn(ExperimentalNativeApi::class) children.replaceAll { child -> if (!child.secondPassVisited) child.processSecondPass() else child } return super.processSecondPassInternal() } diff --git a/libraries/stdlib/wasm/src/kotlin/collections/CollectionsWasm.kt b/libraries/stdlib/wasm/src/kotlin/collections/CollectionsWasm.kt new file mode 100644 index 00000000000..3267a0d11d4 --- /dev/null +++ b/libraries/stdlib/wasm/src/kotlin/collections/CollectionsWasm.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package kotlin.collections + +/** + * Replaces each element in the list with a result of a transformation specified. + */ +public fun MutableList.replaceAll(transformation: (T) -> T) { + val it = listIterator() + while (it.hasNext()) { + val element = it.next() + it.set(transformation(element)) + } +} \ No newline at end of file