From 22255a5cc4235579cdd6e32d863e47be775d310f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 24 Jan 2018 21:28:17 +0300 Subject: [PATCH] stdlib-jvm: move JVM specific sources, add actual modifier where required Update copyright path after moving JVM sources --- .../collections/AbstractMutableCollection.kt | 5 + .../kotlin/collections/AbstractMutableList.kt | 7 +- .../kotlin/collections/AbstractMutableMap.kt | 9 +- .../kotlin/collections/AbstractMutableSet.kt | 9 +- .../src/kotlin/collections/ArraysJVM.kt | 21 +- .../src/kotlin/collections/ArraysUtilJVM.java | 0 .../src/kotlin/collections/CollectionsJVM.kt | 6 +- .../src/kotlin/collections/GroupingJVM.kt | 2 +- .../src/kotlin/collections/IteratorsJVM.kt | 0 .../src/kotlin/collections/MapsJVM.kt | 4 +- .../collections/MutableCollectionsJVM.kt | 10 +- .../src/kotlin/collections/SequencesJVM.kt | 4 +- .../src/kotlin/collections/SetsJVM.kt | 0 .../jvm/src/kotlin/collections/TypeAliases.kt | 13 ++ .../{ => jvm}/src/kotlin/concurrent/Locks.kt | 0 .../{ => jvm}/src/kotlin/concurrent/Thread.kt | 0 .../{ => jvm}/src/kotlin/concurrent/Timer.kt | 0 .../experimental/SafeContinuationJvm.kt | 14 +- .../experimental/intrinsics/IntrinsicsJvm.kt | 8 +- .../jvm/internal/CoroutineImpl.kt | 0 .../jvm/internal/CoroutineIntrinsics.kt | 0 .../internal/PlatformImplementations.kt | 0 .../{ => jvm}/src/kotlin/io/Closeable.kt | 0 .../stdlib/{ => jvm}/src/kotlin/io/Console.kt | 6 +- .../{ => jvm}/src/kotlin/io/Constants.kt | 0 .../{ => jvm}/src/kotlin/io/Exceptions.kt | 0 .../{ => jvm}/src/kotlin/io/FileReadWrite.kt | 0 .../{ => jvm}/src/kotlin/io/IOStreams.kt | 0 .../{ => jvm}/src/kotlin/io/ReadWrite.kt | 0 .../{ => jvm}/src/kotlin/io/Serializable.kt | 3 +- .../src/kotlin/io/files/FilePathComponents.kt | 0 .../src/kotlin/io/files/FileTreeWalk.kt | 0 .../{ => jvm}/src/kotlin/io/files/Utils.kt | 0 .../{ => jvm}/src/kotlin/jvm/JvmDefault.kt | 0 .../{ => jvm}/src/kotlin/jvm/JvmVersion.kt | 0 .../src/kotlin/jvm/internal/unsafe/monitor.kt | 0 .../{ => jvm}/src/kotlin/ranges/RangesJVM.kt | 0 .../{ => jvm}/src/kotlin/system/Process.kt | 0 .../{ => jvm}/src/kotlin/system/Timing.kt | 0 .../{ => jvm}/src/kotlin/text/CharCategory.kt | 0 .../src/kotlin/text/CharDirectionality.kt | 0 .../{ => jvm}/src/kotlin/text/CharJVM.kt | 14 +- .../{ => jvm}/src/kotlin/text/Charsets.kt | 0 .../src/kotlin/text/StringBuilderJVM.kt | 0 .../kotlin/text/StringNumberConversionsJVM.kt | 26 +-- .../{ => jvm}/src/kotlin/text/StringsJVM.kt | 36 ++-- .../{ => jvm}/src/kotlin/text/regex/Regex.kt | 42 ++-- .../kotlin/text/regex/RegexExtensionsJVM.kt | 0 .../src/kotlin/util/AssertionsJVM.kt | 0 .../{ => jvm}/src/kotlin/util/BigDecimals.kt | 0 .../{ => jvm}/src/kotlin/util/BigIntegers.kt | 0 .../{ => jvm}/src/kotlin/util/Exceptions.kt | 0 .../{ => jvm}/src/kotlin/util/LazyJVM.kt | 6 +- .../{ => jvm}/src/kotlin/util/MathJVM.kt | 186 +++++++++--------- .../{ => jvm}/src/kotlin/util/Numbers.kt | 24 +-- .../{ => jvm}/src/kotlin/util/Synchronized.kt | 2 +- .../src/kotlin/collections/TypeAliases.kt | 13 -- license/README.md | 2 +- 58 files changed, 238 insertions(+), 234 deletions(-) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/AbstractMutableCollection.kt (84%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/AbstractMutableList.kt (83%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/AbstractMutableMap.kt (71%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/AbstractMutableSet.kt (65%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/ArraysJVM.kt (61%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/ArraysUtilJVM.java (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/CollectionsJVM.kt (84%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/GroupingJVM.kt (96%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/IteratorsJVM.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/MapsJVM.kt (94%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/MutableCollectionsJVM.kt (86%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/SequencesJVM.kt (85%) rename libraries/stdlib/{ => jvm}/src/kotlin/collections/SetsJVM.kt (100%) create mode 100644 libraries/stdlib/jvm/src/kotlin/collections/TypeAliases.kt rename libraries/stdlib/{ => jvm}/src/kotlin/concurrent/Locks.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/concurrent/Thread.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/concurrent/Timer.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt (89%) rename libraries/stdlib/{ => jvm}/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt (94%) rename libraries/stdlib/{ => jvm}/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/internal/PlatformImplementations.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/Closeable.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/Console.kt (97%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/Constants.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/Exceptions.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/FileReadWrite.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/IOStreams.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/ReadWrite.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/Serializable.kt (80%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/files/FilePathComponents.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/files/FileTreeWalk.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/io/files/Utils.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/jvm/JvmDefault.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/jvm/JvmVersion.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/jvm/internal/unsafe/monitor.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/ranges/RangesJVM.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/system/Process.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/system/Timing.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/CharCategory.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/CharDirectionality.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/CharJVM.kt (88%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/Charsets.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/StringBuilderJVM.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/StringNumberConversionsJVM.kt (89%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/StringsJVM.kt (89%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/regex/Regex.kt (81%) rename libraries/stdlib/{ => jvm}/src/kotlin/text/regex/RegexExtensionsJVM.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/AssertionsJVM.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/BigDecimals.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/BigIntegers.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/Exceptions.kt (100%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/LazyJVM.kt (94%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/MathJVM.kt (79%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/Numbers.kt (66%) rename libraries/stdlib/{ => jvm}/src/kotlin/util/Synchronized.kt (87%) delete mode 100644 libraries/stdlib/src/kotlin/collections/TypeAliases.kt diff --git a/libraries/stdlib/src/kotlin/collections/AbstractMutableCollection.kt b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableCollection.kt similarity index 84% rename from libraries/stdlib/src/kotlin/collections/AbstractMutableCollection.kt rename to libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableCollection.kt index fb164c990c2..a06c8772931 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractMutableCollection.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableCollection.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:JvmVersion package kotlin.collections diff --git a/libraries/stdlib/src/kotlin/collections/AbstractMutableList.kt b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableList.kt similarity index 83% rename from libraries/stdlib/src/kotlin/collections/AbstractMutableList.kt rename to libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableList.kt index c98492db9d9..5f53d035293 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractMutableList.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableList.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:JvmVersion package kotlin.collections @@ -9,7 +14,7 @@ import java.util.AbstractList * @param E the type of elements contained in the list. The list is invariant on its element type. */ @SinceKotlin("1.1") -public abstract class AbstractMutableList protected constructor() : MutableList, AbstractList() { +public actual abstract class AbstractMutableList protected actual constructor() : MutableList, AbstractList() { /** * Replaces the element at the specified position in this list with the specified element. * diff --git a/libraries/stdlib/src/kotlin/collections/AbstractMutableMap.kt b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableMap.kt similarity index 71% rename from libraries/stdlib/src/kotlin/collections/AbstractMutableMap.kt rename to libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableMap.kt index 6920156c16b..a550acac360 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractMutableMap.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableMap.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:JvmVersion package kotlin.collections @@ -12,7 +17,7 @@ import java.util.AbstractMap * @param V the type of map values. The map is invariant on its value type. */ @SinceKotlin("1.1") -public abstract class AbstractMutableMap protected constructor() : MutableMap, AbstractMap() { +public actual abstract class AbstractMutableMap protected actual constructor() : MutableMap, AbstractMap() { /** * Associates the specified [value] with the specified [key] in the map. * @@ -21,5 +26,5 @@ public abstract class AbstractMutableMap protected constructor() : Mutable * * @return the previous value associated with the key, or `null` if the key was not present in the map. */ - abstract override fun put(key: K, value: V): V? + actual abstract override fun put(key: K, value: V): V? } \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/collections/AbstractMutableSet.kt b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableSet.kt similarity index 65% rename from libraries/stdlib/src/kotlin/collections/AbstractMutableSet.kt rename to libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableSet.kt index 5a41f931edd..cb82ec804a7 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractMutableSet.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/AbstractMutableSet.kt @@ -1,3 +1,8 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + @file:JvmVersion package kotlin.collections @@ -9,7 +14,7 @@ import java.util.AbstractSet * @param E the type of elements contained in the set. The set is invariant on its element type. */ @SinceKotlin("1.1") -public abstract class AbstractMutableSet protected constructor() : MutableSet, AbstractSet() { +public actual abstract class AbstractMutableSet protected actual constructor() : MutableSet, AbstractSet() { /** * Adds the specified element to the set. * @@ -18,5 +23,5 @@ public abstract class AbstractMutableSet protected constructor() : MutableSet * * @return `true` if the element has been added, `false` if the element is already contained in the set. */ - abstract override fun add(element: E): Boolean + actual abstract override fun add(element: E): Boolean } \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/ArraysJVM.kt similarity index 61% rename from libraries/stdlib/src/kotlin/collections/ArraysJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/ArraysJVM.kt index 85a7369a339..fe8608f4da3 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/ArraysJVM.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ @file:kotlin.jvm.JvmMultifileClass @@ -27,7 +16,7 @@ import java.nio.charset.Charset * Returns the array if it's not `null`, or an empty array otherwise. * @sample samples.collections.Arrays.Usage.arrayOrEmpty */ -public inline fun Array?.orEmpty(): Array = this ?: emptyArray() +public actual inline fun Array?.orEmpty(): Array = this ?: emptyArray() /** * Converts the contents of this byte array to a string using the specified [charset]. @@ -44,14 +33,14 @@ public inline fun ByteArray.toString(charset: Charset): String = String(this, ch * @sample samples.collections.Collections.Collections.collectionToTypedArray */ @Suppress("UNCHECKED_CAST") -public inline fun Collection.toTypedArray(): Array { +public actual inline fun Collection.toTypedArray(): Array { @Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN") val thisCollection = this as java.util.Collection return thisCollection.toArray(arrayOfNulls(0)) as Array } /** Internal unsafe construction of array based on reference array type */ -internal fun arrayOfNulls(reference: Array, size: Int): Array { +internal actual fun arrayOfNulls(reference: Array, size: Int): Array { @Suppress("UNCHECKED_CAST") return java.lang.reflect.Array.newInstance(reference.javaClass.componentType, size) as Array } diff --git a/libraries/stdlib/src/kotlin/collections/ArraysUtilJVM.java b/libraries/stdlib/jvm/src/kotlin/collections/ArraysUtilJVM.java similarity index 100% rename from libraries/stdlib/src/kotlin/collections/ArraysUtilJVM.java rename to libraries/stdlib/jvm/src/kotlin/collections/ArraysUtilJVM.java diff --git a/libraries/stdlib/src/kotlin/collections/CollectionsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/CollectionsJVM.kt similarity index 84% rename from libraries/stdlib/src/kotlin/collections/CollectionsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/CollectionsJVM.kt index 781f3c18325..4e21073a99d 100644 --- a/libraries/stdlib/src/kotlin/collections/CollectionsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/CollectionsJVM.kt @@ -31,17 +31,17 @@ public inline fun java.util.Enumeration.toList(): List = java.util.Col @JvmVersion @kotlin.internal.InlineOnly -internal inline fun copyToArrayImpl(collection: Collection<*>): Array = +internal actual inline fun copyToArrayImpl(collection: Collection<*>): Array = kotlin.jvm.internal.collectionToArray(collection) @JvmVersion @kotlin.internal.InlineOnly -internal inline fun copyToArrayImpl(collection: Collection<*>, array: Array): Array = +internal actual inline fun copyToArrayImpl(collection: Collection<*>, array: Array): Array = kotlin.jvm.internal.collectionToArray(collection, array as Array) as Array // copies typed varargs array to array of objects @JvmVersion -internal fun Array.copyToArrayOfAny(isVarargs: Boolean): Array = +internal actual fun Array.copyToArrayOfAny(isVarargs: Boolean): Array = if (isVarargs && this.javaClass == Array::class.java) // if the array came from varargs and already is array of Any, copying isn't required @Suppress("UNCHECKED_CAST") (this as Array) diff --git a/libraries/stdlib/src/kotlin/collections/GroupingJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/GroupingJVM.kt similarity index 96% rename from libraries/stdlib/src/kotlin/collections/GroupingJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/GroupingJVM.kt index cbef4f6f713..de41064ae7a 100644 --- a/libraries/stdlib/src/kotlin/collections/GroupingJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/GroupingJVM.kt @@ -18,7 +18,7 @@ package kotlin.collections */ @SinceKotlin("1.1") @JvmVersion -public fun Grouping.eachCount(): Map = +public actual fun Grouping.eachCount(): Map = // fold(0) { acc, e -> acc + 1 } optimized for boxing foldTo(destination = mutableMapOf(), initialValueSelector = { _, _ -> kotlin.jvm.internal.Ref.IntRef() }, diff --git a/libraries/stdlib/src/kotlin/collections/IteratorsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/IteratorsJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/collections/IteratorsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/IteratorsJVM.kt diff --git a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt similarity index 94% rename from libraries/stdlib/src/kotlin/collections/MapsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt index 7744fc66360..8001b667d83 100644 --- a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt @@ -80,10 +80,10 @@ public inline fun Map.toProperties(): Properties // creates a singleton copy of map, if there is specialization available in target platform, otherwise returns itself @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -internal inline fun Map.toSingletonMapOrSelf(): Map = toSingletonMap() +internal actual inline fun Map.toSingletonMapOrSelf(): Map = toSingletonMap() // creates a singleton copy of map @kotlin.jvm.JvmVersion -internal fun Map.toSingletonMap(): Map +internal actual fun Map.toSingletonMap(): Map = with (entries.iterator().next()) { java.util.Collections.singletonMap(key, value) } diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollectionsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/MutableCollectionsJVM.kt similarity index 86% rename from libraries/stdlib/src/kotlin/collections/MutableCollectionsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/MutableCollectionsJVM.kt index 2f5ae2cc2c1..1899feda9d6 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollectionsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/MutableCollectionsJVM.kt @@ -26,7 +26,7 @@ public inline fun MutableList.sort(comparison: (T, T) -> Int): Unit = thr * Sorts elements in the list in-place according to their natural sort order. */ @kotlin.jvm.JvmVersion -public fun > MutableList.sort(): Unit { +public actual fun > MutableList.sort(): Unit { if (size > 1) java.util.Collections.sort(this) } @@ -34,7 +34,7 @@ public fun > MutableList.sort(): Unit { * Sorts elements in the list in-place according to the order specified with [comparator]. */ @kotlin.jvm.JvmVersion -public fun MutableList.sortWith(comparator: Comparator): Unit { +public actual fun MutableList.sortWith(comparator: Comparator): Unit { if (size > 1) java.util.Collections.sort(this, comparator) } @@ -46,7 +46,7 @@ public fun MutableList.sortWith(comparator: Comparator): Unit { @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly @SinceKotlin("1.2") -public inline fun MutableList.fill(value: T) { +public actual inline fun MutableList.fill(value: T) { java.util.Collections.fill(this, value) } @@ -57,7 +57,7 @@ public inline fun MutableList.fill(value: T) { @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly @SinceKotlin("1.2") -public inline fun MutableList.shuffle() { +public actual inline fun MutableList.shuffle() { java.util.Collections.shuffle(this) } @@ -76,7 +76,7 @@ public inline fun MutableList.shuffle(random: java.util.Random) { */ @kotlin.jvm.JvmVersion @SinceKotlin("1.2") -public fun Iterable.shuffled(): List = toMutableList().apply { shuffle() } +public actual fun Iterable.shuffled(): List = toMutableList().apply { shuffle() } /** * Returns a new list with the elements of this list randomly shuffled diff --git a/libraries/stdlib/src/kotlin/collections/SequencesJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/SequencesJVM.kt similarity index 85% rename from libraries/stdlib/src/kotlin/collections/SequencesJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/SequencesJVM.kt index 969b38a26c7..b4c2515a646 100644 --- a/libraries/stdlib/src/kotlin/collections/SequencesJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/SequencesJVM.kt @@ -20,10 +20,10 @@ public inline fun java.util.Enumeration.asSequence(): Sequence = this.i @kotlin.jvm.JvmVersion -internal class ConstrainedOnceSequence(sequence: Sequence) : Sequence { +internal actual class ConstrainedOnceSequence actual constructor(sequence: Sequence) : Sequence { private val sequenceRef = java.util.concurrent.atomic.AtomicReference(sequence) - override fun iterator(): Iterator { + actual override fun iterator(): Iterator { val sequence = sequenceRef.getAndSet(null) ?: throw IllegalStateException("This sequence can be consumed only once.") return sequence.iterator() } diff --git a/libraries/stdlib/src/kotlin/collections/SetsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/SetsJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/collections/SetsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/collections/SetsJVM.kt diff --git a/libraries/stdlib/jvm/src/kotlin/collections/TypeAliases.kt b/libraries/stdlib/jvm/src/kotlin/collections/TypeAliases.kt new file mode 100644 index 00000000000..291f32fc926 --- /dev/null +++ b/libraries/stdlib/jvm/src/kotlin/collections/TypeAliases.kt @@ -0,0 +1,13 @@ +@file:kotlin.jvm.JvmVersion + +package kotlin.collections + +@SinceKotlin("1.1") public actual typealias RandomAccess = java.util.RandomAccess + + +@SinceKotlin("1.1") public actual typealias ArrayList = java.util.ArrayList +@SinceKotlin("1.1") public actual typealias LinkedHashMap = java.util.LinkedHashMap +@SinceKotlin("1.1") public actual typealias HashMap = java.util.HashMap +@SinceKotlin("1.1") public actual typealias LinkedHashSet = java.util.LinkedHashSet +@SinceKotlin("1.1") public actual typealias HashSet = java.util.HashSet + diff --git a/libraries/stdlib/src/kotlin/concurrent/Locks.kt b/libraries/stdlib/jvm/src/kotlin/concurrent/Locks.kt similarity index 100% rename from libraries/stdlib/src/kotlin/concurrent/Locks.kt rename to libraries/stdlib/jvm/src/kotlin/concurrent/Locks.kt diff --git a/libraries/stdlib/src/kotlin/concurrent/Thread.kt b/libraries/stdlib/jvm/src/kotlin/concurrent/Thread.kt similarity index 100% rename from libraries/stdlib/src/kotlin/concurrent/Thread.kt rename to libraries/stdlib/jvm/src/kotlin/concurrent/Thread.kt diff --git a/libraries/stdlib/src/kotlin/concurrent/Timer.kt b/libraries/stdlib/jvm/src/kotlin/concurrent/Timer.kt similarity index 100% rename from libraries/stdlib/src/kotlin/concurrent/Timer.kt rename to libraries/stdlib/jvm/src/kotlin/concurrent/Timer.kt diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt similarity index 89% rename from libraries/stdlib/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt rename to libraries/stdlib/jvm/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt index be5c57cc857..cc9a6c4e506 100644 --- a/libraries/stdlib/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt +++ b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/SafeContinuationJvm.kt @@ -21,16 +21,16 @@ import kotlin.* import kotlin.coroutines.experimental.intrinsics.COROUTINE_SUSPENDED @PublishedApi -internal class SafeContinuation -internal constructor( +internal actual class SafeContinuation +internal actual constructor( private val delegate: Continuation, initialResult: Any? ) : Continuation { @PublishedApi - internal constructor(delegate: Continuation) : this(delegate, UNDECIDED) + internal actual constructor(delegate: Continuation) : this(delegate, UNDECIDED) - public override val context: CoroutineContext + public actual override val context: CoroutineContext get() = delegate.context @Volatile @@ -48,7 +48,7 @@ internal constructor( private class Fail(val exception: Throwable) - override fun resume(value: T) { + actual override fun resume(value: T) { while (true) { // lock-free loop val result = this.result // atomic read when { @@ -62,7 +62,7 @@ internal constructor( } } - override fun resumeWithException(exception: Throwable) { + actual override fun resumeWithException(exception: Throwable) { while (true) { // lock-free loop val result = this.result // atomic read when { @@ -77,7 +77,7 @@ internal constructor( } @PublishedApi - internal fun getResult(): Any? { + internal actual fun getResult(): Any? { var result = this.result // atomic read if (result === UNDECIDED) { if (RESULT.compareAndSet(this, UNDECIDED, COROUTINE_SUSPENDED)) return COROUTINE_SUSPENDED diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt similarity index 94% rename from libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt rename to libraries/stdlib/jvm/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt index 5d6b8287bea..ba079f7755d 100644 --- a/libraries/stdlib/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt +++ b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/intrinsics/IntrinsicsJvm.kt @@ -30,7 +30,7 @@ import kotlin.coroutines.experimental.* @SinceKotlin("1.1") @Suppress("UNCHECKED_CAST") @kotlin.internal.InlineOnly -public inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( +public actual inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( completion: Continuation ): Any? = (this as Function1, Any?>).invoke(completion) @@ -44,7 +44,7 @@ public inline fun (suspend () -> T).startCoroutineUninterceptedOrReturn( @SinceKotlin("1.1") @Suppress("UNCHECKED_CAST") @kotlin.internal.InlineOnly -public inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn( +public actual inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn( receiver: R, completion: Continuation ): Any? = (this as Function2, Any?>).invoke(receiver, completion) @@ -64,7 +64,7 @@ public inline fun (suspend R.() -> T).startCoroutineUninterceptedOrReturn */ @SinceKotlin("1.1") @kotlin.jvm.JvmVersion -public fun (suspend () -> T).createCoroutineUnchecked( +public actual fun (suspend () -> T).createCoroutineUnchecked( completion: Continuation ): Continuation = if (this !is kotlin.coroutines.experimental.jvm.internal.CoroutineImpl) @@ -87,7 +87,7 @@ public fun (suspend () -> T).createCoroutineUnchecked( */ @SinceKotlin("1.1") @kotlin.jvm.JvmVersion -public fun (suspend R.() -> T).createCoroutineUnchecked( +public actual fun (suspend R.() -> T).createCoroutineUnchecked( receiver: R, completion: Continuation ): Continuation = diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt similarity index 100% rename from libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt rename to libraries/stdlib/jvm/src/kotlin/coroutines/experimental/jvm/internal/CoroutineImpl.kt diff --git a/libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt b/libraries/stdlib/jvm/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt similarity index 100% rename from libraries/stdlib/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt rename to libraries/stdlib/jvm/src/kotlin/coroutines/experimental/jvm/internal/CoroutineIntrinsics.kt diff --git a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt b/libraries/stdlib/jvm/src/kotlin/internal/PlatformImplementations.kt similarity index 100% rename from libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt rename to libraries/stdlib/jvm/src/kotlin/internal/PlatformImplementations.kt diff --git a/libraries/stdlib/src/kotlin/io/Closeable.kt b/libraries/stdlib/jvm/src/kotlin/io/Closeable.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/Closeable.kt rename to libraries/stdlib/jvm/src/kotlin/io/Closeable.kt diff --git a/libraries/stdlib/src/kotlin/io/Console.kt b/libraries/stdlib/jvm/src/kotlin/io/Console.kt similarity index 97% rename from libraries/stdlib/src/kotlin/io/Console.kt rename to libraries/stdlib/jvm/src/kotlin/io/Console.kt index 6b32a6abf8e..06a3fd5471f 100644 --- a/libraries/stdlib/src/kotlin/io/Console.kt +++ b/libraries/stdlib/jvm/src/kotlin/io/Console.kt @@ -13,7 +13,7 @@ import java.nio.charset.CharsetDecoder /** Prints the given message to the standard output stream. */ @kotlin.internal.InlineOnly -public inline fun print(message: Any?) { +public actual inline fun print(message: Any?) { System.out.print(message) } @@ -73,7 +73,7 @@ public inline fun print(message: CharArray) { /** Prints the given message and newline to the standard output stream. */ @kotlin.internal.InlineOnly -public inline fun println(message: Any?) { +public actual inline fun println(message: Any?) { System.out.println(message) } @@ -133,7 +133,7 @@ public inline fun println(message: CharArray) { /** Prints a newline to the standard output stream. */ @kotlin.internal.InlineOnly -public inline fun println() { +public actual inline fun println() { System.out.println() } diff --git a/libraries/stdlib/src/kotlin/io/Constants.kt b/libraries/stdlib/jvm/src/kotlin/io/Constants.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/Constants.kt rename to libraries/stdlib/jvm/src/kotlin/io/Constants.kt diff --git a/libraries/stdlib/src/kotlin/io/Exceptions.kt b/libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/Exceptions.kt rename to libraries/stdlib/jvm/src/kotlin/io/Exceptions.kt diff --git a/libraries/stdlib/src/kotlin/io/FileReadWrite.kt b/libraries/stdlib/jvm/src/kotlin/io/FileReadWrite.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/FileReadWrite.kt rename to libraries/stdlib/jvm/src/kotlin/io/FileReadWrite.kt diff --git a/libraries/stdlib/src/kotlin/io/IOStreams.kt b/libraries/stdlib/jvm/src/kotlin/io/IOStreams.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/IOStreams.kt rename to libraries/stdlib/jvm/src/kotlin/io/IOStreams.kt diff --git a/libraries/stdlib/src/kotlin/io/ReadWrite.kt b/libraries/stdlib/jvm/src/kotlin/io/ReadWrite.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/ReadWrite.kt rename to libraries/stdlib/jvm/src/kotlin/io/ReadWrite.kt diff --git a/libraries/stdlib/src/kotlin/io/Serializable.kt b/libraries/stdlib/jvm/src/kotlin/io/Serializable.kt similarity index 80% rename from libraries/stdlib/src/kotlin/io/Serializable.kt rename to libraries/stdlib/jvm/src/kotlin/io/Serializable.kt index bfae0469d6e..987087faf4a 100644 --- a/libraries/stdlib/src/kotlin/io/Serializable.kt +++ b/libraries/stdlib/jvm/src/kotlin/io/Serializable.kt @@ -17,4 +17,5 @@ package kotlin.io // to use in shared code without imports -internal typealias Serializable = java.io.Serializable \ No newline at end of file +@Suppress("ACTUAL_WITHOUT_EXPECT") // internal expect is not matched with internal typealias to public type +internal actual typealias Serializable = java.io.Serializable \ No newline at end of file diff --git a/libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt b/libraries/stdlib/jvm/src/kotlin/io/files/FilePathComponents.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/files/FilePathComponents.kt rename to libraries/stdlib/jvm/src/kotlin/io/files/FilePathComponents.kt diff --git a/libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt b/libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/files/FileTreeWalk.kt rename to libraries/stdlib/jvm/src/kotlin/io/files/FileTreeWalk.kt diff --git a/libraries/stdlib/src/kotlin/io/files/Utils.kt b/libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt similarity index 100% rename from libraries/stdlib/src/kotlin/io/files/Utils.kt rename to libraries/stdlib/jvm/src/kotlin/io/files/Utils.kt diff --git a/libraries/stdlib/src/kotlin/jvm/JvmDefault.kt b/libraries/stdlib/jvm/src/kotlin/jvm/JvmDefault.kt similarity index 100% rename from libraries/stdlib/src/kotlin/jvm/JvmDefault.kt rename to libraries/stdlib/jvm/src/kotlin/jvm/JvmDefault.kt diff --git a/libraries/stdlib/src/kotlin/jvm/JvmVersion.kt b/libraries/stdlib/jvm/src/kotlin/jvm/JvmVersion.kt similarity index 100% rename from libraries/stdlib/src/kotlin/jvm/JvmVersion.kt rename to libraries/stdlib/jvm/src/kotlin/jvm/JvmVersion.kt diff --git a/libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt b/libraries/stdlib/jvm/src/kotlin/jvm/internal/unsafe/monitor.kt similarity index 100% rename from libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt rename to libraries/stdlib/jvm/src/kotlin/jvm/internal/unsafe/monitor.kt diff --git a/libraries/stdlib/src/kotlin/ranges/RangesJVM.kt b/libraries/stdlib/jvm/src/kotlin/ranges/RangesJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/ranges/RangesJVM.kt rename to libraries/stdlib/jvm/src/kotlin/ranges/RangesJVM.kt diff --git a/libraries/stdlib/src/kotlin/system/Process.kt b/libraries/stdlib/jvm/src/kotlin/system/Process.kt similarity index 100% rename from libraries/stdlib/src/kotlin/system/Process.kt rename to libraries/stdlib/jvm/src/kotlin/system/Process.kt diff --git a/libraries/stdlib/src/kotlin/system/Timing.kt b/libraries/stdlib/jvm/src/kotlin/system/Timing.kt similarity index 100% rename from libraries/stdlib/src/kotlin/system/Timing.kt rename to libraries/stdlib/jvm/src/kotlin/system/Timing.kt diff --git a/libraries/stdlib/src/kotlin/text/CharCategory.kt b/libraries/stdlib/jvm/src/kotlin/text/CharCategory.kt similarity index 100% rename from libraries/stdlib/src/kotlin/text/CharCategory.kt rename to libraries/stdlib/jvm/src/kotlin/text/CharCategory.kt diff --git a/libraries/stdlib/src/kotlin/text/CharDirectionality.kt b/libraries/stdlib/jvm/src/kotlin/text/CharDirectionality.kt similarity index 100% rename from libraries/stdlib/src/kotlin/text/CharDirectionality.kt rename to libraries/stdlib/jvm/src/kotlin/text/CharDirectionality.kt diff --git a/libraries/stdlib/src/kotlin/text/CharJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt similarity index 88% rename from libraries/stdlib/src/kotlin/text/CharJVM.kt rename to libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt index c25e9621edc..8eae71499d9 100644 --- a/libraries/stdlib/src/kotlin/text/CharJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt @@ -76,7 +76,7 @@ public inline fun Char.isJavaIdentifierStart(): Boolean = Character.isJavaIdenti * Determines whether a character is whitespace according to the Unicode standard. * Returns `true` if the character is whitespace. */ -public fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) || Character.isSpaceChar(this) +public actual fun Char.isWhitespace(): Boolean = Character.isWhitespace(this) || Character.isSpaceChar(this) /** * Returns `true` if this character is upper case. @@ -94,13 +94,13 @@ public inline fun Char.isLowerCase(): Boolean = Character.isLowerCase(this) * Converts this character to uppercase. */ @kotlin.internal.InlineOnly -public inline fun Char.toUpperCase(): Char = Character.toUpperCase(this) +public actual inline fun Char.toUpperCase(): Char = Character.toUpperCase(this) /** * Converts this character to lowercase. */ @kotlin.internal.InlineOnly -public inline fun Char.toLowerCase(): Char = Character.toLowerCase(this) +public actual inline fun Char.toLowerCase(): Char = Character.toLowerCase(this) /** * Returns `true` if this character is a titlecase character. @@ -130,13 +130,13 @@ public val Char.directionality: CharDirectionality get() = CharDirectionality.va * Returns `true` if this character is a Unicode high-surrogate code unit (also known as leading-surrogate code unit). */ @kotlin.internal.InlineOnly -public inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) +public actual inline fun Char.isHighSurrogate(): Boolean = Character.isHighSurrogate(this) /** * Returns `true` if this character is a Unicode low-surrogate code unit (also known as trailing-surrogate code unit). */ @kotlin.internal.InlineOnly -public inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this) +public actual inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this) // TODO Provide name for JVM7+ ///** @@ -146,13 +146,13 @@ public inline fun Char.isLowSurrogate(): Boolean = Character.isLowSurrogate(this -internal fun digitOf(char: Char, radix: Int): Int = Character.digit(char.toInt(), radix) +internal actual fun digitOf(char: Char, radix: Int): Int = Character.digit(char.toInt(), radix) /** * Checks whether the given [radix] is valid radix for string to number and number to string conversion. */ @PublishedApi -internal fun checkRadix(radix: Int): Int { +internal actual fun checkRadix(radix: Int): Int { if(radix !in Character.MIN_RADIX..Character.MAX_RADIX) { throw IllegalArgumentException("radix $radix was not in valid range ${Character.MIN_RADIX..Character.MAX_RADIX}") } diff --git a/libraries/stdlib/src/kotlin/text/Charsets.kt b/libraries/stdlib/jvm/src/kotlin/text/Charsets.kt similarity index 100% rename from libraries/stdlib/src/kotlin/text/Charsets.kt rename to libraries/stdlib/jvm/src/kotlin/text/Charsets.kt diff --git a/libraries/stdlib/src/kotlin/text/StringBuilderJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/StringBuilderJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/text/StringBuilderJVM.kt rename to libraries/stdlib/jvm/src/kotlin/text/StringBuilderJVM.kt diff --git a/libraries/stdlib/src/kotlin/text/StringNumberConversionsJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/StringNumberConversionsJVM.kt similarity index 89% rename from libraries/stdlib/src/kotlin/text/StringNumberConversionsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/text/StringNumberConversionsJVM.kt index 2372e9e82d1..9268f7d505d 100644 --- a/libraries/stdlib/src/kotlin/text/StringNumberConversionsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/StringNumberConversionsJVM.kt @@ -57,7 +57,7 @@ public inline fun Long.toString(radix: Int): String = java.lang.Long.toString(th */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this) +public actual inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(this) /** * Parses the string as a signed [Byte] number and returns the result. @@ -65,7 +65,7 @@ public inline fun String.toBoolean(): Boolean = java.lang.Boolean.parseBoolean(t */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this) +public actual inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this) /** * Parses the string as a signed [Byte] number and returns the result. @@ -75,7 +75,7 @@ public inline fun String.toByte(): Byte = java.lang.Byte.parseByte(this) @SinceKotlin("1.1") @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(this, checkRadix(radix)) +public actual inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(this, checkRadix(radix)) /** @@ -84,7 +84,7 @@ public inline fun String.toByte(radix: Int): Byte = java.lang.Byte.parseByte(thi */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toShort(): Short = java.lang.Short.parseShort(this) +public actual inline fun String.toShort(): Short = java.lang.Short.parseShort(this) /** * Parses the string as a [Short] number and returns the result. @@ -94,7 +94,7 @@ public inline fun String.toShort(): Short = java.lang.Short.parseShort(this) @SinceKotlin("1.1") @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort(this, checkRadix(radix)) +public actual inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort(this, checkRadix(radix)) /** * Parses the string as an [Int] number and returns the result. @@ -102,7 +102,7 @@ public inline fun String.toShort(radix: Int): Short = java.lang.Short.parseShort */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toInt(): Int = java.lang.Integer.parseInt(this) +public actual inline fun String.toInt(): Int = java.lang.Integer.parseInt(this) /** * Parses the string as an [Int] number and returns the result. @@ -112,7 +112,7 @@ public inline fun String.toInt(): Int = java.lang.Integer.parseInt(this) @SinceKotlin("1.1") @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(this, checkRadix(radix)) +public actual inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(this, checkRadix(radix)) /** * Parses the string as a [Long] number and returns the result. @@ -120,7 +120,7 @@ public inline fun String.toInt(radix: Int): Int = java.lang.Integer.parseInt(thi */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toLong(): Long = java.lang.Long.parseLong(this) +public actual inline fun String.toLong(): Long = java.lang.Long.parseLong(this) /** * Parses the string as a [Long] number and returns the result. @@ -130,7 +130,7 @@ public inline fun String.toLong(): Long = java.lang.Long.parseLong(this) @SinceKotlin("1.1") @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, checkRadix(radix)) +public actual inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(this, checkRadix(radix)) /** * Parses the string as a [Float] number and returns the result. @@ -138,7 +138,7 @@ public inline fun String.toLong(radix: Int): Long = java.lang.Long.parseLong(thi */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this) +public actual inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this) /** * Parses the string as a [Double] number and returns the result. @@ -146,7 +146,7 @@ public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this) */ @kotlin.jvm.JvmVersion @kotlin.internal.InlineOnly -public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this) +public actual inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this) /** @@ -155,7 +155,7 @@ public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this) */ @SinceKotlin("1.1") @kotlin.jvm.JvmVersion -public fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Float::parseFloat) +public actual fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Float::parseFloat) /** * Parses the string as a [Double] number and returns the result @@ -163,7 +163,7 @@ public fun String.toFloatOrNull(): Float? = screenFloatValue(this, java.lang.Flo */ @SinceKotlin("1.1") @kotlin.jvm.JvmVersion -public fun String.toDoubleOrNull(): Double? = screenFloatValue(this, java.lang.Double::parseDouble) +public actual fun String.toDoubleOrNull(): Double? = screenFloatValue(this, java.lang.Double::parseDouble) /** * Parses the string as a [java.math.BigInteger] number and returns the result. diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt similarity index 89% rename from libraries/stdlib/src/kotlin/text/StringsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt index 621a3fd244f..79efa4bb52b 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt @@ -14,32 +14,32 @@ import java.util.regex.Pattern * Returns the index within this string of the first occurrence of the specified character, starting from the specified offset. */ @kotlin.internal.InlineOnly -internal inline fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex) +internal actual inline fun String.nativeIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).indexOf(ch.toInt(), fromIndex) /** * Returns the index within this string of the first occurrence of the specified substring, starting from the specified offset. */ @kotlin.internal.InlineOnly -internal inline fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex) +internal actual inline fun String.nativeIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).indexOf(str, fromIndex) /** * Returns the index within this string of the last occurrence of the specified character. */ @kotlin.internal.InlineOnly -internal inline fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex) +internal actual inline fun String.nativeLastIndexOf(ch: Char, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(ch.toInt(), fromIndex) /** * Returns the index within this string of the last occurrence of the specified character, starting from the specified offset. */ @kotlin.internal.InlineOnly -internal inline fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex) +internal actual inline fun String.nativeLastIndexOf(str: String, fromIndex: Int): Int = (this as java.lang.String).lastIndexOf(str, fromIndex) /** * Returns `true` if this string is equal to [other], optionally ignoring character case. * * @param ignoreCase `true` to ignore character case when comparing strings. By default `false`. */ -public fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean { +public actual fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean { if (this === null) return other === null return if (!ignoreCase) @@ -51,7 +51,7 @@ public fun String?.equals(other: String?, ignoreCase: Boolean = false): Boolean /** * Returns a new string with all occurrences of [oldChar] replaced with [newChar]. */ -public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { +public actual fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { if (!ignoreCase) return (this as java.lang.String).replace(oldChar, newChar) else @@ -62,14 +62,14 @@ public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = fa * Returns a new string obtained by replacing all occurrences of the [oldValue] substring in this string * with the specified [newValue] string. */ -public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String = +public actual fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String = splitToSequence(oldValue, ignoreCase = ignoreCase).joinToString(separator = newValue) /** * Returns a new string with the first occurrence of [oldChar] replaced with [newChar]. */ -public fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { +public actual fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { val index = indexOf(oldChar, ignoreCase = ignoreCase) return if (index < 0) this else this.replaceRange(index, index + 1, newChar.toString()) } @@ -78,7 +78,7 @@ public fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean * Returns a new string obtained by replacing the first occurrence of the [oldValue] substring in this string * with the specified [newValue] string. */ -public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String { +public actual fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String { val index = indexOf(oldValue, ignoreCase = ignoreCase) return if (index < 0) this else this.replaceRange(index, index + oldValue.length, newValue) } @@ -87,13 +87,13 @@ public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: B * Returns a copy of this string converted to upper case using the rules of the default locale. */ @kotlin.internal.InlineOnly -public inline fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase() +public actual inline fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase() /** * Returns a copy of this string converted to lower case using the rules of the default locale. */ @kotlin.internal.InlineOnly -public inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() +public actual inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() /** * Returns a new character array containing the characters from this string. @@ -159,7 +159,7 @@ public fun CharSequence.split(regex: Pattern, limit: Int = 0): List * Returns a substring of this string that starts at the specified [startIndex] and continues to the end of the string. */ @kotlin.internal.InlineOnly -public inline fun String.substring(startIndex: Int): String = (this as java.lang.String).substring(startIndex) +public actual inline fun String.substring(startIndex: Int): String = (this as java.lang.String).substring(startIndex) /** * Returns the substring of this string starting at the [startIndex] and ending right before the [endIndex]. @@ -168,7 +168,7 @@ public inline fun String.substring(startIndex: Int): String = (this as java.lang * @param endIndex the end index (exclusive). */ @kotlin.internal.InlineOnly -public inline fun String.substring(startIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(startIndex, endIndex) +public actual inline fun String.substring(startIndex: Int, endIndex: Int): String = (this as java.lang.String).substring(startIndex, endIndex) /** * Returns `true` if this string starts with the specified prefix. @@ -318,7 +318,7 @@ public inline fun String.intern(): String = (this as java.lang.String).intern() /** * Returns `true` if this string is empty or consists solely of whitespace characters. */ -public fun CharSequence.isBlank(): Boolean = length == 0 || indices.all { this[it].isWhitespace() } +public actual fun CharSequence.isBlank(): Boolean = length == 0 || indices.all { this[it].isWhitespace() } /** * Returns the index within this string that is offset from the given [index] by [codePointOffset] code points. @@ -333,7 +333,7 @@ public inline fun String.offsetByCodePoints(index: Int, codePointOffset: Int): I * @param otherOffset the start offset in the other char sequence of the substring to compare. * @param length the length of the substring to compare. */ -public fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean { +public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequence, otherOffset: Int, length: Int, ignoreCase: Boolean = false): Boolean { if (this is String && other is String) return this.regionMatches(thisOffset, other, otherOffset, length, ignoreCase) else @@ -388,7 +388,7 @@ public inline fun String.toPattern(flags: Int = 0): java.util.regex.Pattern { * * @sample samples.text.Strings.capitalize */ -public fun String.capitalize(): String { +public actual fun String.capitalize(): String { return if (isNotEmpty() && this[0].isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this } @@ -398,7 +398,7 @@ public fun String.capitalize(): String { * * @sample samples.text.Strings.decapitalize */ -public fun String.decapitalize(): String { +public actual fun String.decapitalize(): String { return if (isNotEmpty() && this[0].isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this } @@ -407,7 +407,7 @@ public fun String.decapitalize(): String { * @throws [IllegalArgumentException] when n < 0. * @sample samples.text.Strings.repeat */ -public fun CharSequence.repeat(n: Int): String { +public actual fun CharSequence.repeat(n: Int): String { require (n >= 0) { "Count 'n' must be non-negative, but was $n." } return when (n) { diff --git a/libraries/stdlib/src/kotlin/text/regex/Regex.kt b/libraries/stdlib/jvm/src/kotlin/text/regex/Regex.kt similarity index 81% rename from libraries/stdlib/src/kotlin/text/regex/Regex.kt rename to libraries/stdlib/jvm/src/kotlin/text/regex/Regex.kt index 9a8a86cae10..547b9a4260c 100644 --- a/libraries/stdlib/src/kotlin/text/regex/Regex.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/regex/Regex.kt @@ -36,7 +36,7 @@ private inline fun fromInt(value: Int): Set where T : FlagEnum, T /** * Provides enumeration values to use to set regular expression options. */ -public enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum { +public actual enum class RegexOption(override val value: Int, override val mask: Int = value) : FlagEnum { // common /** Enables case-insensitive matching. Case comparison is Unicode-aware. */ @@ -86,41 +86,41 @@ public enum class RegexOption(override val value: Int, override val mask: Int = * * The [range] property is available on JVM only. */ -public data class MatchGroup(public val value: String, public val range: IntRange) +public actual data class MatchGroup(public actual val value: String, public val range: IntRange) /** * Represents an immutable regular expression. * * For pattern syntax reference see [Pattern] */ -public class Regex +public actual class Regex @PublishedApi internal constructor(private val nativePattern: Pattern) : Serializable { /** Creates a regular expression from the specified [pattern] string and the default options. */ - public constructor(pattern: String): this(Pattern.compile(pattern)) + public actual constructor(pattern: String): this(Pattern.compile(pattern)) /** Creates a regular expression from the specified [pattern] string and the specified single [option]. */ - public constructor(pattern: String, option: RegexOption): this(Pattern.compile(pattern, ensureUnicodeCase(option.value))) + public actual constructor(pattern: String, option: RegexOption): this(Pattern.compile(pattern, ensureUnicodeCase(option.value))) /** Creates a regular expression from the specified [pattern] string and the specified set of [options]. */ - public constructor(pattern: String, options: Set): this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt()))) + public actual constructor(pattern: String, options: Set): this(Pattern.compile(pattern, ensureUnicodeCase(options.toInt()))) /** The pattern string of this regular expression. */ - public val pattern: String + public actual val pattern: String get() = nativePattern.pattern() private var _options: Set? = null /** The set of options that were used to create this regular expression. */ - public val options: Set get() = _options ?: fromInt(nativePattern.flags()).also { _options = it } + public actual val options: Set get() = _options ?: fromInt(nativePattern.flags()).also { _options = it } /** Indicates whether the regular expression matches the entire [input]. */ - public infix fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches() + public actual infix fun matches(input: CharSequence): Boolean = nativePattern.matcher(input).matches() /** Indicates whether the regular expression can find at least one match in the specified [input]. */ - public fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find() + public actual fun containsMatchIn(input: CharSequence): Boolean = nativePattern.matcher(input).find() /** * Returns the first match of a regular expression in the [input], beginning at the specified [startIndex]. @@ -128,33 +128,33 @@ internal constructor(private val nativePattern: Pattern) : Serializable { * @param startIndex An index to start search with, by default 0. Must be not less than zero and not greater than `input.length()` * @return An instance of [MatchResult] if match was found or `null` otherwise. */ - public fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.matcher(input).findNext(startIndex, input) + public actual fun find(input: CharSequence, startIndex: Int = 0): MatchResult? = nativePattern.matcher(input).findNext(startIndex, input) /** * Returns a sequence of all occurrences of a regular expression within the [input] string, beginning at the specified [startIndex]. */ - public fun findAll(input: CharSequence, startIndex: Int = 0): Sequence = generateSequence({ find(input, startIndex) }, MatchResult::next) + public actual fun findAll(input: CharSequence, startIndex: Int = 0): Sequence = generateSequence({ find(input, startIndex) }, MatchResult::next) /** * Attempts to match the entire [input] CharSequence against the pattern. * * @return An instance of [MatchResult] if the entire input matches or `null` otherwise. */ - public fun matchEntire(input: CharSequence): MatchResult? = nativePattern.matcher(input).matchEntire(input) + public actual fun matchEntire(input: CharSequence): MatchResult? = nativePattern.matcher(input).matchEntire(input) /** * Replaces all occurrences of this regular expression in the specified [input] string with specified [replacement] expression. * * @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details. */ - public fun replace(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceAll(replacement) + public actual fun replace(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceAll(replacement) /** * Replaces all occurrences of this regular expression in the specified [input] string with the result of * the given function [transform] that takes [MatchResult] and returns a string to be used as a * replacement for that match. */ - public fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String { + public actual fun replace(input: CharSequence, transform: (MatchResult) -> CharSequence): String { var match: MatchResult? = find(input) ?: return input.toString() var lastStart = 0 @@ -180,7 +180,7 @@ internal constructor(private val nativePattern: Pattern) : Serializable { * * @param replacement A replacement expression that can include substitutions. See [Matcher.appendReplacement] for details. */ - public fun replaceFirst(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceFirst(replacement) + public actual fun replaceFirst(input: CharSequence, replacement: String): String = nativePattern.matcher(input).replaceFirst(replacement) /** @@ -189,7 +189,7 @@ internal constructor(private val nativePattern: Pattern) : Serializable { * @param limit Non-negative value specifying the maximum number of substrings the string can be split to. * Zero by default means no limit is set. */ - public fun split(input: CharSequence, limit: Int = 0): List { + public actual fun split(input: CharSequence, limit: Int = 0): List { require(limit >= 0, { "Limit must be non-negative, but was $limit." } ) return nativePattern.split(input, if (limit == 0) -1 else limit).asList() } @@ -214,13 +214,13 @@ internal constructor(private val nativePattern: Pattern) : Serializable { private fun readResolve(): Any = Regex(Pattern.compile(pattern, flags)) } - companion object { + actual companion object { /** Returns a literal regex for the specified [literal] string. */ - public fun fromLiteral(literal: String): Regex = literal.toRegex(RegexOption.LITERAL) + public actual fun fromLiteral(literal: String): Regex = literal.toRegex(RegexOption.LITERAL) /** Returns a literal pattern for the specified [literal] string. */ - public fun escape(literal: String): String = Pattern.quote(literal) + public actual fun escape(literal: String): String = Pattern.quote(literal) /** Returns a literal replacement expression for the specified [literal] string. */ - public fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal) + public actual fun escapeReplacement(literal: String): String = Matcher.quoteReplacement(literal) private fun ensureUnicodeCase(flags: Int) = if (flags and Pattern.CASE_INSENSITIVE != 0) flags or Pattern.UNICODE_CASE else flags } diff --git a/libraries/stdlib/src/kotlin/text/regex/RegexExtensionsJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/regex/RegexExtensionsJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/text/regex/RegexExtensionsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/text/regex/RegexExtensionsJVM.kt diff --git a/libraries/stdlib/src/kotlin/util/AssertionsJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/AssertionsJVM.kt similarity index 100% rename from libraries/stdlib/src/kotlin/util/AssertionsJVM.kt rename to libraries/stdlib/jvm/src/kotlin/util/AssertionsJVM.kt diff --git a/libraries/stdlib/src/kotlin/util/BigDecimals.kt b/libraries/stdlib/jvm/src/kotlin/util/BigDecimals.kt similarity index 100% rename from libraries/stdlib/src/kotlin/util/BigDecimals.kt rename to libraries/stdlib/jvm/src/kotlin/util/BigDecimals.kt diff --git a/libraries/stdlib/src/kotlin/util/BigIntegers.kt b/libraries/stdlib/jvm/src/kotlin/util/BigIntegers.kt similarity index 100% rename from libraries/stdlib/src/kotlin/util/BigIntegers.kt rename to libraries/stdlib/jvm/src/kotlin/util/BigIntegers.kt diff --git a/libraries/stdlib/src/kotlin/util/Exceptions.kt b/libraries/stdlib/jvm/src/kotlin/util/Exceptions.kt similarity index 100% rename from libraries/stdlib/src/kotlin/util/Exceptions.kt rename to libraries/stdlib/jvm/src/kotlin/util/Exceptions.kt diff --git a/libraries/stdlib/src/kotlin/util/LazyJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/LazyJVM.kt similarity index 94% rename from libraries/stdlib/src/kotlin/util/LazyJVM.kt rename to libraries/stdlib/jvm/src/kotlin/util/LazyJVM.kt index 0446d030892..63f662a0d7f 100644 --- a/libraries/stdlib/src/kotlin/util/LazyJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/LazyJVM.kt @@ -19,7 +19,7 @@ package kotlin * the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future. */ @kotlin.jvm.JvmVersion -public fun lazy(initializer: () -> T): Lazy = SynchronizedLazyImpl(initializer) +public actual fun lazy(initializer: () -> T): Lazy = SynchronizedLazyImpl(initializer) /** * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer] @@ -32,7 +32,7 @@ public fun lazy(initializer: () -> T): Lazy = SynchronizedLazyImpl(initia * Also this behavior can be changed in the future. */ @kotlin.jvm.JvmVersion -public fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy = +public actual fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy = when (mode) { LazyThreadSafetyMode.SYNCHRONIZED -> SynchronizedLazyImpl(initializer) LazyThreadSafetyMode.PUBLICATION -> SafePublicationLazyImpl(initializer) @@ -51,7 +51,7 @@ public fun lazy(mode: LazyThreadSafetyMode, initializer: () -> T): Lazy = * Also this behavior can be changed in the future. */ @kotlin.jvm.JvmVersion -public fun lazy(lock: Any?, initializer: () -> T): Lazy = SynchronizedLazyImpl(initializer, lock) +public actual fun lazy(lock: Any?, initializer: () -> T): Lazy = SynchronizedLazyImpl(initializer, lock) diff --git a/libraries/stdlib/src/kotlin/util/MathJVM.kt b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt similarity index 79% rename from libraries/stdlib/src/kotlin/util/MathJVM.kt rename to libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt index 1b757a182f6..64f3708eb54 100644 --- a/libraries/stdlib/src/kotlin/util/MathJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt @@ -24,12 +24,6 @@ import kotlin.internal.InlineOnly import java.lang.Math as nativeMath // constants -/** Ratio of the circumference of a circle to its diameter, approximately 3.14159. */ -@SinceKotlin("1.2") -public const val PI: Double = nativeMath.PI -/** Base of the natural logarithms, approximately 2.71828. */ -@SinceKotlin("1.2") -public const val E: Double = nativeMath.E /** Natural logarithm of 2.0, used to compute [log2] function */ private val LN2: Double = ln(2.0) @@ -48,7 +42,7 @@ private val upper_taylor_n_bound = 1 / taylor_n_bound */ @SinceKotlin("1.2") @InlineOnly -public inline fun sin(x: Double): Double = nativeMath.sin(x) +public actual inline fun sin(x: Double): Double = nativeMath.sin(x) /** Computes the cosine of the angle [x] given in radians. * @@ -57,7 +51,7 @@ public inline fun sin(x: Double): Double = nativeMath.sin(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun cos(x: Double): Double = nativeMath.cos(x) +public actual inline fun cos(x: Double): Double = nativeMath.cos(x) /** Computes the tangent of the angle [x] given in radians. * @@ -66,7 +60,7 @@ public inline fun cos(x: Double): Double = nativeMath.cos(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun tan(x: Double): Double = nativeMath.tan(x) +public actual inline fun tan(x: Double): Double = nativeMath.tan(x) /** * Computes the arc sine of the value [x]; @@ -77,7 +71,7 @@ public inline fun tan(x: Double): Double = nativeMath.tan(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun asin(x: Double): Double = nativeMath.asin(x) +public actual inline fun asin(x: Double): Double = nativeMath.asin(x) /** * Computes the arc cosine of the value [x]; @@ -88,7 +82,7 @@ public inline fun asin(x: Double): Double = nativeMath.asin(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun acos(x: Double): Double = nativeMath.acos(x) +public actual inline fun acos(x: Double): Double = nativeMath.acos(x) /** * Computes the arc tangent of the value [x]; @@ -99,7 +93,7 @@ public inline fun acos(x: Double): Double = nativeMath.acos(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun atan(x: Double): Double = nativeMath.atan(x) +public actual inline fun atan(x: Double): Double = nativeMath.atan(x) /** * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond @@ -119,7 +113,7 @@ public inline fun atan(x: Double): Double = nativeMath.atan(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x) +public actual inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x) /** * Computes the hyperbolic sine of the value [x]. @@ -131,7 +125,7 @@ public inline fun atan2(y: Double, x: Double): Double = nativeMath.atan2(y, x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun sinh(x: Double): Double = nativeMath.sinh(x) +public actual inline fun sinh(x: Double): Double = nativeMath.sinh(x) /** * Computes the hyperbolic cosine of the value [x]. @@ -142,7 +136,7 @@ public inline fun sinh(x: Double): Double = nativeMath.sinh(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun cosh(x: Double): Double = nativeMath.cosh(x) +public actual inline fun cosh(x: Double): Double = nativeMath.cosh(x) /** * Computes the hyperbolic tangent of the value [x]. @@ -154,7 +148,7 @@ public inline fun cosh(x: Double): Double = nativeMath.cosh(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun tanh(x: Double): Double = nativeMath.tanh(x) +public actual inline fun tanh(x: Double): Double = nativeMath.tanh(x) // Inverse hyperbolic function implementations derived from boost special math functions, @@ -171,7 +165,7 @@ public inline fun tanh(x: Double): Double = nativeMath.tanh(x) * - `asinh(-Inf)` is `-Inf` */ @SinceKotlin("1.2") -public fun asinh(x: Double): Double = +public actual fun asinh(x: Double): Double = when { x >= +taylor_n_bound -> if (x > upper_taylor_n_bound) { @@ -209,7 +203,7 @@ public fun asinh(x: Double): Double = * - `acosh(+Inf)` is `+Inf` */ @SinceKotlin("1.2") -public fun acosh(x: Double): Double = +public actual fun acosh(x: Double): Double = when { x < 1 -> Double.NaN @@ -245,7 +239,7 @@ public fun acosh(x: Double): Double = * - `tanh(-1.0)` is `-Inf` */ @SinceKotlin("1.2") -public fun atanh(x: Double): Double { +public actual fun atanh(x: Double): Double { if (nativeMath.abs(x) < taylor_n_bound) { var result = x if (nativeMath.abs(x) > taylor_2_bound) { @@ -265,7 +259,7 @@ public fun atanh(x: Double): Double { */ @SinceKotlin("1.2") @InlineOnly -public inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y) +public actual inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y) /** * Computes the positive square root of the value [x]. @@ -275,7 +269,7 @@ public inline fun hypot(x: Double, y: Double): Double = nativeMath.hypot(x, y) */ @SinceKotlin("1.2") @InlineOnly -public inline fun sqrt(x: Double): Double = nativeMath.sqrt(x) +public actual inline fun sqrt(x: Double): Double = nativeMath.sqrt(x) /** * Computes Euler's number `e` raised to the power of the value [x]. @@ -287,7 +281,7 @@ public inline fun sqrt(x: Double): Double = nativeMath.sqrt(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun exp(x: Double): Double = nativeMath.exp(x) +public actual inline fun exp(x: Double): Double = nativeMath.exp(x) /** * Computes `exp(x) - 1`. @@ -303,7 +297,7 @@ public inline fun exp(x: Double): Double = nativeMath.exp(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun expm1(x: Double): Double = nativeMath.expm1(x) +public actual inline fun expm1(x: Double): Double = nativeMath.expm1(x) /** * Computes the logarithm of the value [x] to the given [base]. @@ -318,7 +312,7 @@ public inline fun expm1(x: Double): Double = nativeMath.expm1(x) * See also logarithm functions for common fixed bases: [ln], [log10] and [log2]. */ @SinceKotlin("1.2") -public fun log(x: Double, base: Double): Double { +public actual fun log(x: Double, base: Double): Double { if (base <= 0.0 || base == 1.0) return Double.NaN return nativeMath.log(x) / nativeMath.log(base) } @@ -334,7 +328,7 @@ public fun log(x: Double, base: Double): Double { */ @SinceKotlin("1.2") @InlineOnly -public inline fun ln(x: Double): Double = nativeMath.log(x) +public actual inline fun ln(x: Double): Double = nativeMath.log(x) /** * Computes the common logarithm (base 10) of the value [x]. @@ -343,7 +337,7 @@ public inline fun ln(x: Double): Double = nativeMath.log(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun log10(x: Double): Double = nativeMath.log10(x) +public actual inline fun log10(x: Double): Double = nativeMath.log10(x) /** * Computes the binary logarithm (base 2) of the value [x]. @@ -351,7 +345,7 @@ public inline fun log10(x: Double): Double = nativeMath.log10(x) * @see [ln] function for special cases. */ @SinceKotlin("1.2") -public fun log2(x: Double): Double = nativeMath.log(x) / LN2 +public actual fun log2(x: Double): Double = nativeMath.log(x) / LN2 /** * Computes `ln(x + 1)`. @@ -369,7 +363,7 @@ public fun log2(x: Double): Double = nativeMath.log(x) / LN2 */ @SinceKotlin("1.2") @InlineOnly -public inline fun ln1p(x: Double): Double = nativeMath.log1p(x) +public actual inline fun ln1p(x: Double): Double = nativeMath.log1p(x) /** * Rounds the given value [x] to an integer towards positive infinity. @@ -381,7 +375,7 @@ public inline fun ln1p(x: Double): Double = nativeMath.log1p(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun ceil(x: Double): Double = nativeMath.ceil(x) +public actual inline fun ceil(x: Double): Double = nativeMath.ceil(x) /** * Rounds the given value [x] to an integer towards negative infinity. @@ -393,7 +387,7 @@ public inline fun ceil(x: Double): Double = nativeMath.ceil(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun floor(x: Double): Double = nativeMath.floor(x) +public actual inline fun floor(x: Double): Double = nativeMath.floor(x) /** * Rounds the given value [x] to an integer towards zero. @@ -404,7 +398,7 @@ public inline fun floor(x: Double): Double = nativeMath.floor(x) * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. */ @SinceKotlin("1.2") -public fun truncate(x: Double): Double = when { +public actual fun truncate(x: Double): Double = when { x.isNaN() || x.isInfinite() -> x x > 0 -> floor(x) else -> ceil(x) @@ -418,7 +412,7 @@ public fun truncate(x: Double): Double = when { */ @SinceKotlin("1.2") @InlineOnly -public inline fun round(x: Double): Double = nativeMath.rint(x) +public actual inline fun round(x: Double): Double = nativeMath.rint(x) /** @@ -431,7 +425,7 @@ public inline fun round(x: Double): Double = nativeMath.rint(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun abs(x: Double): Double = nativeMath.abs(x) +public actual inline fun abs(x: Double): Double = nativeMath.abs(x) /** * Returns the sign of the given value [x]: @@ -444,7 +438,7 @@ public inline fun abs(x: Double): Double = nativeMath.abs(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun sign(x: Double): Double = nativeMath.signum(x) +public actual inline fun sign(x: Double): Double = nativeMath.signum(x) @@ -455,7 +449,7 @@ public inline fun sign(x: Double): Double = nativeMath.signum(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b) +public actual inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b) /** * Returns the greater of two values. * @@ -463,7 +457,7 @@ public inline fun min(a: Double, b: Double): Double = nativeMath.min(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b) +public actual inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b) // extensions @@ -481,7 +475,7 @@ public inline fun max(a: Double, b: Double): Double = nativeMath.max(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x) +public actual inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x) /** * Raises this value to the integer power [n]. @@ -490,7 +484,7 @@ public inline fun Double.pow(x: Double): Double = nativeMath.pow(this, x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble()) +public actual inline fun Double.pow(n: Int): Double = nativeMath.pow(this, n.toDouble()) /** * Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard. @@ -518,7 +512,7 @@ public inline fun Double.IEEErem(divisor: Double): Double = nativeMath.IEEEremai */ @SinceKotlin("1.2") @InlineOnly -public inline val Double.absoluteValue: Double get() = nativeMath.abs(this) +public actual inline val Double.absoluteValue: Double get() = nativeMath.abs(this) /** * Returns the sign of this value: @@ -531,7 +525,7 @@ public inline val Double.absoluteValue: Double get() = nativeMath.abs(this) */ @SinceKotlin("1.2") @InlineOnly -public inline val Double.sign: Double get() = nativeMath.signum(this) +public actual inline val Double.sign: Double get() = nativeMath.signum(this) /** * Returns this value with the sign bit same as of the [sign] value. @@ -540,13 +534,13 @@ public inline val Double.sign: Double get() = nativeMath.signum(this) */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.withSign(sign: Double): Double = nativeMath.copySign(this, sign) +public actual inline fun Double.withSign(sign: Double): Double = nativeMath.copySign(this, sign) /** * Returns this value with the sign bit same as of the [sign] value. */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this, sign.toDouble()) +public actual inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this, sign.toDouble()) /** * Returns the ulp (unit in the last place) of this value. @@ -560,20 +554,20 @@ public inline fun Double.withSign(sign: Int): Double = nativeMath.copySign(this, */ @SinceKotlin("1.2") @InlineOnly -public inline val Double.ulp: Double get() = nativeMath.ulp(this) +public actual inline val Double.ulp: Double get() = nativeMath.ulp(this) /** * Returns the [Double] value nearest to this value in direction of positive infinity. */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.nextUp(): Double = nativeMath.nextUp(this) +public actual inline fun Double.nextUp(): Double = nativeMath.nextUp(this) /** * Returns the [Double] value nearest to this value in direction of negative infinity. */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double.NEGATIVE_INFINITY) +public actual inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double.NEGATIVE_INFINITY) /** * Returns the [Double] value nearest to this value in direction from this value towards the value [to]. @@ -585,7 +579,7 @@ public inline fun Double.nextDown(): Double = nativeMath.nextAfter(this, Double. */ @SinceKotlin("1.2") @InlineOnly -public inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter(this, to) +public actual inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter(this, to) /** * Rounds this [Double] value to the nearest integer and converts the result to [Int]. @@ -598,7 +592,7 @@ public inline fun Double.nextTowards(to: Double): Double = nativeMath.nextAfter( * @throws IllegalArgumentException when this value is `NaN` */ @SinceKotlin("1.2") -public fun Double.roundToInt(): Int = when { +public actual fun Double.roundToInt(): Int = when { isNaN() -> throw IllegalArgumentException("Cannot round NaN value.") this > Int.MAX_VALUE -> Int.MAX_VALUE this < Int.MIN_VALUE -> Int.MIN_VALUE @@ -616,7 +610,7 @@ public fun Double.roundToInt(): Int = when { * @throws IllegalArgumentException when this value is `NaN` */ @SinceKotlin("1.2") -public fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) +public actual fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) @@ -629,7 +623,7 @@ public fun Double.roundToLong(): Long = if (isNaN()) throw IllegalArgumentExcept */ @SinceKotlin("1.2") @InlineOnly -public inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat() +public actual inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat() /** Computes the cosine of the angle [x] given in radians. * @@ -638,7 +632,7 @@ public inline fun sin(x: Float): Float = nativeMath.sin(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat() +public actual inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat() /** Computes the tangent of the angle [x] given in radians. * @@ -647,7 +641,7 @@ public inline fun cos(x: Float): Float = nativeMath.cos(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat() +public actual inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat() /** * Computes the arc sine of the value [x]; @@ -658,7 +652,7 @@ public inline fun tan(x: Float): Float = nativeMath.tan(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat() +public actual inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat() /** * Computes the arc cosine of the value [x]; @@ -669,7 +663,7 @@ public inline fun asin(x: Float): Float = nativeMath.asin(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat() +public actual inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat() /** * Computes the arc tangent of the value [x]; @@ -680,7 +674,7 @@ public inline fun acos(x: Float): Float = nativeMath.acos(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat() +public actual inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat() /** * Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond @@ -700,7 +694,7 @@ public inline fun atan(x: Float): Float = nativeMath.atan(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat() +public actual inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble(), x.toDouble()).toFloat() /** * Computes the hyperbolic sine of the value [x]. @@ -712,7 +706,7 @@ public inline fun atan2(y: Float, x: Float): Float = nativeMath.atan2(y.toDouble */ @SinceKotlin("1.2") @InlineOnly -public inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat() +public actual inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat() /** * Computes the hyperbolic cosine of the value [x]. @@ -723,7 +717,7 @@ public inline fun sinh(x: Float): Float = nativeMath.sinh(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat() +public actual inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat() /** * Computes the hyperbolic tangent of the value [x]. @@ -735,7 +729,7 @@ public inline fun cosh(x: Float): Float = nativeMath.cosh(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat() +public actual inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat() /** * Computes the inverse hyperbolic sine of the value [x]. @@ -749,7 +743,7 @@ public inline fun tanh(x: Float): Float = nativeMath.tanh(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat() +public actual inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat() /** * Computes the inverse hyperbolic cosine of the value [x]. @@ -763,7 +757,7 @@ public inline fun asinh(x: Float): Float = asinh(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat() +public actual inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat() /** * Computes the inverse hyperbolic tangent of the value [x]. @@ -778,7 +772,7 @@ public inline fun acosh(x: Float): Float = acosh(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat() +public actual inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat() /** * Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow. @@ -789,7 +783,7 @@ public inline fun atanh(x: Float): Float = atanh(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat() +public actual inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble(), y.toDouble()).toFloat() /** * Computes the positive square root of the value [x]. @@ -799,7 +793,7 @@ public inline fun hypot(x: Float, y: Float): Float = nativeMath.hypot(x.toDouble */ @SinceKotlin("1.2") @InlineOnly -public inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat() +public actual inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat() /** * Computes Euler's number `e` raised to the power of the value [x]. @@ -811,7 +805,7 @@ public inline fun sqrt(x: Float): Float = nativeMath.sqrt(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat() +public actual inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat() /** * Computes `exp(x) - 1`. @@ -827,7 +821,7 @@ public inline fun exp(x: Float): Float = nativeMath.exp(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat() +public actual inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloat() /** * Computes the logarithm of the value [x] to the given [base]. @@ -842,7 +836,7 @@ public inline fun expm1(x: Float): Float = nativeMath.expm1(x.toDouble()).toFloa * See also logarithm functions for common fixed bases: [ln], [log10] and [log2]. */ @SinceKotlin("1.2") -public fun log(x: Float, base: Float): Float { +public actual fun log(x: Float, base: Float): Float { if (base <= 0.0F || base == 1.0F) return Float.NaN return (nativeMath.log(x.toDouble()) / nativeMath.log(base.toDouble())).toFloat() } @@ -858,7 +852,7 @@ public fun log(x: Float, base: Float): Float { */ @SinceKotlin("1.2") @InlineOnly -public inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat() +public actual inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat() /** * Computes the common logarithm (base 10) of the value [x]. @@ -867,7 +861,7 @@ public inline fun ln(x: Float): Float = nativeMath.log(x.toDouble()).toFloat() */ @SinceKotlin("1.2") @InlineOnly -public inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat() +public actual inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloat() /** * Computes the binary logarithm (base 2) of the value [x]. @@ -875,7 +869,7 @@ public inline fun log10(x: Float): Float = nativeMath.log10(x.toDouble()).toFloa * @see [ln] function for special cases. */ @SinceKotlin("1.2") -public fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat() +public actual fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat() /** * Computes `ln(a + 1)`. @@ -893,7 +887,7 @@ public fun log2(x: Float): Float = (nativeMath.log(x.toDouble()) / LN2).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat() +public actual inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat() /** * Rounds the given value [x] to an integer towards positive infinity. @@ -905,7 +899,7 @@ public inline fun ln1p(x: Float): Float = nativeMath.log1p(x.toDouble()).toFloat */ @SinceKotlin("1.2") @InlineOnly -public inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat() +public actual inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat() /** * Rounds the given value [x] to an integer towards negative infinity. @@ -917,7 +911,7 @@ public inline fun ceil(x: Float): Float = nativeMath.ceil(x.toDouble()).toFloat( */ @SinceKotlin("1.2") @InlineOnly -public inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat() +public actual inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloat() /** * Rounds the given value [x] to an integer towards zero. @@ -928,7 +922,7 @@ public inline fun floor(x: Float): Float = nativeMath.floor(x.toDouble()).toFloa * - `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. */ @SinceKotlin("1.2") -public fun truncate(x: Float): Float = when { +public actual fun truncate(x: Float): Float = when { x.isNaN() || x.isInfinite() -> x x > 0 -> floor(x) else -> ceil(x) @@ -942,7 +936,7 @@ public fun truncate(x: Float): Float = when { */ @SinceKotlin("1.2") @InlineOnly -public inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat() +public actual inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat() /** @@ -955,7 +949,7 @@ public inline fun round(x: Float): Float = nativeMath.rint(x.toDouble()).toFloat */ @SinceKotlin("1.2") @InlineOnly -public inline fun abs(x: Float): Float = nativeMath.abs(x) +public actual inline fun abs(x: Float): Float = nativeMath.abs(x) /** * Returns the sign of the given value [x]: @@ -968,7 +962,7 @@ public inline fun abs(x: Float): Float = nativeMath.abs(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun sign(x: Float): Float = nativeMath.signum(x) +public actual inline fun sign(x: Float): Float = nativeMath.signum(x) @@ -979,7 +973,7 @@ public inline fun sign(x: Float): Float = nativeMath.signum(x) */ @SinceKotlin("1.2") @InlineOnly -public inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b) +public actual inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b) /** * Returns the greater of two values. * @@ -987,7 +981,7 @@ public inline fun min(a: Float, b: Float): Float = nativeMath.min(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b) +public actual inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b) // extensions @@ -1005,7 +999,7 @@ public inline fun max(a: Float, b: Float): Float = nativeMath.max(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat() +public actual inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x.toDouble()).toFloat() /** * Raises this value to the integer power [n]. @@ -1014,7 +1008,7 @@ public inline fun Float.pow(x: Float): Float = nativeMath.pow(this.toDouble(), x */ @SinceKotlin("1.2") @InlineOnly -public inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat() +public actual inline fun Float.pow(n: Int): Float = nativeMath.pow(this.toDouble(), n.toDouble()).toFloat() /** * Computes the remainder of division of this value by the [divisor] value according to the IEEE 754 standard. @@ -1042,7 +1036,7 @@ public inline fun Float.IEEErem(divisor: Float): Float = nativeMath.IEEEremainde */ @SinceKotlin("1.2") @InlineOnly -public inline val Float.absoluteValue: Float get() = nativeMath.abs(this) +public actual inline val Float.absoluteValue: Float get() = nativeMath.abs(this) /** * Returns the sign of this value: @@ -1055,7 +1049,7 @@ public inline val Float.absoluteValue: Float get() = nativeMath.abs(this) */ @SinceKotlin("1.2") @InlineOnly -public inline val Float.sign: Float get() = nativeMath.signum(this) +public actual inline val Float.sign: Float get() = nativeMath.signum(this) /** * Returns this value with the sign bit same as of the [sign] value. @@ -1064,13 +1058,13 @@ public inline val Float.sign: Float get() = nativeMath.signum(this) */ @SinceKotlin("1.2") @InlineOnly -public inline fun Float.withSign(sign: Float): Float = nativeMath.copySign(this, sign) +public actual inline fun Float.withSign(sign: Float): Float = nativeMath.copySign(this, sign) /** * Returns this value with the sign bit same as of the [sign] value. */ @SinceKotlin("1.2") @InlineOnly -public inline fun Float.withSign(sign: Int): Float = nativeMath.copySign(this, sign.toFloat()) +public actual inline fun Float.withSign(sign: Int): Float = nativeMath.copySign(this, sign.toFloat()) /** * Returns the ulp of this value. @@ -1122,7 +1116,7 @@ public inline fun Float.nextTowards(to: Float): Float = nativeMath.nextAfter(thi * @throws IllegalArgumentException when this value is `NaN` */ @SinceKotlin("1.2") -public fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) +public actual fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException("Cannot round NaN value.") else nativeMath.round(this) /** * Rounds this [Float] value to the nearest integer and converts the result to [Long]. @@ -1135,7 +1129,7 @@ public fun Float.roundToInt(): Int = if (isNaN()) throw IllegalArgumentException * @throws IllegalArgumentException when this value is `NaN` */ @SinceKotlin("1.2") -public fun Float.roundToLong(): Long = toDouble().roundToLong() +public actual fun Float.roundToLong(): Long = toDouble().roundToLong() @@ -1151,21 +1145,21 @@ public fun Float.roundToLong(): Long = toDouble().roundToLong() */ @SinceKotlin("1.2") @InlineOnly -public inline fun abs(n: Int): Int = nativeMath.abs(n) +public actual inline fun abs(n: Int): Int = nativeMath.abs(n) /** * Returns the smaller of two values. */ @SinceKotlin("1.2") @InlineOnly -public inline fun min(a: Int, b: Int): Int = nativeMath.min(a, b) +public actual inline fun min(a: Int, b: Int): Int = nativeMath.min(a, b) /** * Returns the greater of two values. */ @SinceKotlin("1.2") @InlineOnly -public inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b) +public actual inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b) /** * Returns the absolute value of this value. @@ -1177,7 +1171,7 @@ public inline fun max(a: Int, b: Int): Int = nativeMath.max(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline val Int.absoluteValue: Int get() = nativeMath.abs(this) +public actual inline val Int.absoluteValue: Int get() = nativeMath.abs(this) /** * Returns the sign of this value: @@ -1186,7 +1180,7 @@ public inline val Int.absoluteValue: Int get() = nativeMath.abs(this) * - `1` if the value is positive */ @SinceKotlin("1.2") -public val Int.sign: Int get() = when { +public actual val Int.sign: Int get() = when { this < 0 -> -1 this > 0 -> 1 else -> 0 @@ -1204,21 +1198,21 @@ public val Int.sign: Int get() = when { */ @SinceKotlin("1.2") @InlineOnly -public inline fun abs(n: Long): Long = nativeMath.abs(n) +public actual inline fun abs(n: Long): Long = nativeMath.abs(n) /** * Returns the smaller of two values. */ @SinceKotlin("1.2") @InlineOnly -public inline fun min(a: Long, b: Long): Long = nativeMath.min(a, b) +public actual inline fun min(a: Long, b: Long): Long = nativeMath.min(a, b) /** * Returns the greater of two values. */ @SinceKotlin("1.2") @InlineOnly -public inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b) +public actual inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b) /** * Returns the absolute value of this value. @@ -1230,7 +1224,7 @@ public inline fun max(a: Long, b: Long): Long = nativeMath.max(a, b) */ @SinceKotlin("1.2") @InlineOnly -public inline val Long.absoluteValue: Long get() = nativeMath.abs(this) +public actual inline val Long.absoluteValue: Long get() = nativeMath.abs(this) /** * Returns the sign of this value: @@ -1239,7 +1233,7 @@ public inline val Long.absoluteValue: Long get() = nativeMath.abs(this) * - `1` if the value is positive */ @SinceKotlin("1.2") -public val Long.sign: Int get() = when { +public actual val Long.sign: Int get() = when { this < 0 -> -1 this > 0 -> 1 else -> 0 diff --git a/libraries/stdlib/src/kotlin/util/Numbers.kt b/libraries/stdlib/jvm/src/kotlin/util/Numbers.kt similarity index 66% rename from libraries/stdlib/src/kotlin/util/Numbers.kt rename to libraries/stdlib/jvm/src/kotlin/util/Numbers.kt index 00ff9569e9f..9a27c8ab3d9 100644 --- a/libraries/stdlib/src/kotlin/util/Numbers.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/Numbers.kt @@ -8,38 +8,38 @@ package kotlin * Not-a-Number (NaN) value, `false` otherwise. */ @kotlin.internal.InlineOnly -public inline fun Double.isNaN(): Boolean = java.lang.Double.isNaN(this) +public actual inline fun Double.isNaN(): Boolean = java.lang.Double.isNaN(this) /** * Returns `true` if the specified number is a * Not-a-Number (NaN) value, `false` otherwise. */ @kotlin.internal.InlineOnly -public inline fun Float.isNaN(): Boolean = java.lang.Float.isNaN(this) +public actual inline fun Float.isNaN(): Boolean = java.lang.Float.isNaN(this) /** * Returns `true` if this value is infinitely large in magnitude. */ @kotlin.internal.InlineOnly -public inline fun Double.isInfinite(): Boolean = java.lang.Double.isInfinite(this) +public actual inline fun Double.isInfinite(): Boolean = java.lang.Double.isInfinite(this) /** * Returns `true` if this value is infinitely large in magnitude. */ @kotlin.internal.InlineOnly -public inline fun Float.isInfinite(): Boolean = java.lang.Float.isInfinite(this) +public actual inline fun Float.isInfinite(): Boolean = java.lang.Float.isInfinite(this) /** * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). */ @kotlin.internal.InlineOnly -public inline fun Double.isFinite(): Boolean = !isInfinite() && !isNaN() +public actual inline fun Double.isFinite(): Boolean = !isInfinite() && !isNaN() /** * Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). */ @kotlin.internal.InlineOnly -public inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN() +public actual inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN() /** * Returns a bit representation of the specified floating-point value as [Long] @@ -47,7 +47,7 @@ public inline fun Float.isFinite(): Boolean = !isInfinite() && !isNaN() */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this) +public actual inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this) /** * Returns a bit representation of the specified floating-point value as [Long] @@ -56,14 +56,14 @@ public inline fun Double.toBits(): Long = java.lang.Double.doubleToLongBits(this */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Double.toRawBits(): Long = java.lang.Double.doubleToRawLongBits(this) +public actual inline fun Double.toRawBits(): Long = java.lang.Double.doubleToRawLongBits(this) /** * Returns the [Double] value corresponding to a given bit representation. */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Double.longBitsToDouble(bits) +public actual inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Double.longBitsToDouble(bits) /** * Returns a bit representation of the specified floating-point value as [Int] @@ -71,7 +71,7 @@ public inline fun Double.Companion.fromBits(bits: Long): Double = java.lang.Doub */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this) +public actual inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this) /** * Returns a bit representation of the specified floating-point value as [Int] @@ -80,11 +80,11 @@ public inline fun Float.toBits(): Int = java.lang.Float.floatToIntBits(this) */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Float.toRawBits(): Int = java.lang.Float.floatToRawIntBits(this) +public actual inline fun Float.toRawBits(): Int = java.lang.Float.floatToRawIntBits(this) /** * Returns the [Float] value corresponding to a given bit representation. */ @SinceKotlin("1.2") @kotlin.internal.InlineOnly -public inline fun Float.Companion.fromBits(bits: Int): Float = java.lang.Float.intBitsToFloat(bits) +public actual inline fun Float.Companion.fromBits(bits: Int): Float = java.lang.Float.intBitsToFloat(bits) diff --git a/libraries/stdlib/src/kotlin/util/Synchronized.kt b/libraries/stdlib/jvm/src/kotlin/util/Synchronized.kt similarity index 87% rename from libraries/stdlib/src/kotlin/util/Synchronized.kt rename to libraries/stdlib/jvm/src/kotlin/util/Synchronized.kt index a2de14c91e7..6491271031d 100644 --- a/libraries/stdlib/src/kotlin/util/Synchronized.kt +++ b/libraries/stdlib/jvm/src/kotlin/util/Synchronized.kt @@ -9,7 +9,7 @@ import kotlin.jvm.internal.unsafe.* * Executes the given function [block] while holding the monitor of the given object [lock]. */ @kotlin.internal.InlineOnly -public inline fun synchronized(lock: Any, block: () -> R): R { +public actual inline fun synchronized(lock: Any, block: () -> R): R { @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE", "INVISIBLE_MEMBER") monitorEnter(lock) try { diff --git a/libraries/stdlib/src/kotlin/collections/TypeAliases.kt b/libraries/stdlib/src/kotlin/collections/TypeAliases.kt deleted file mode 100644 index b34b2eff610..00000000000 --- a/libraries/stdlib/src/kotlin/collections/TypeAliases.kt +++ /dev/null @@ -1,13 +0,0 @@ -@file:kotlin.jvm.JvmVersion - -package kotlin.collections - -@SinceKotlin("1.1") public typealias RandomAccess = java.util.RandomAccess - - -@SinceKotlin("1.1") public typealias ArrayList = java.util.ArrayList -@SinceKotlin("1.1") public typealias LinkedHashMap = java.util.LinkedHashMap -@SinceKotlin("1.1") public typealias HashMap = java.util.HashMap -@SinceKotlin("1.1") public typealias LinkedHashSet = java.util.LinkedHashSet -@SinceKotlin("1.1") public typealias HashSet = java.util.HashSet - diff --git a/license/README.md b/license/README.md index e9b9d41c68f..30e435599fe 100644 --- a/license/README.md +++ b/license/README.md @@ -53,7 +53,7 @@ the Kotlin IntelliJ IDEA plugin: - License: Apache 2 (license/third_party/gwt_license.txt) - Origin: Derived from GWT, (C) 2007-08 Google Inc. - - Path: libraries/stdlib/src/kotlin/util/MathJVM.kt + - Path: libraries/stdlib/jvm/src/kotlin/util/MathJVM.kt - License: Boost Software License 1.0 (license/third_party/boost_LICENSE.txt) - Origin: Derived from boost special math functions, Copyright Eric Ford & Hubert Holin 2001.