From a69a583c6400e6b02b680409e780d8d652c2070f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 28 Jul 2017 18:03:03 +0300 Subject: [PATCH] Deprecate kotlin.js.Math object, rename kotlin.math.kt to just math.kt --- js/js.libraries/src/core/js.math.kt | 28 ++++++++++++++++++- .../src/core/{kotlin.math.kt => math.kt} | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) rename js/js.libraries/src/core/{kotlin.math.kt => math.kt} (99%) diff --git a/js/js.libraries/src/core/js.math.kt b/js/js.libraries/src/core/js.math.kt index dd48abfa358..7d0b52e2ebd 100644 --- a/js/js.libraries/src/core/js.math.kt +++ b/js/js.libraries/src/core/js.math.kt @@ -1,32 +1,54 @@ package kotlin.js -//TODO: deprecate /** * Exposes the JavaScript [Math object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math) to Kotlin. */ +@Deprecated("Use top-level functions from kotlin.math package instead.") public external object Math { + @Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI")) public val PI: Double public fun random(): Double + @Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs")) public fun abs(value: Double): Double + @Deprecated("Use kotlin.math.acos instead.", ReplaceWith("acos(value)", "kotlin.math.acos")) public fun acos(value: Double): Double + @Deprecated("Use kotlin.math.asin instead.", ReplaceWith("asin(value)", "kotlin.math.asin")) public fun asin(value: Double): Double + @Deprecated("Use kotlin.math.atan instead.", ReplaceWith("atan(value)", "kotlin.math.atan")) public fun atan(value: Double): Double + @Deprecated("Use kotlin.math.atan2 instead.", ReplaceWith("atan2(y, x)", "kotlin.math.atan2")) public fun atan2(y: Double, x: Double): Double + @Deprecated("Use kotlin.math.cos instead.", ReplaceWith("cos(value)", "kotlin.math.cos")) public fun cos(value: Double): Double + @Deprecated("Use kotlin.math.sin instead.", ReplaceWith("sin(value)", "kotlin.math.sin")) public fun sin(value: Double): Double + @Deprecated("Use kotlin.math.exp instead.", ReplaceWith("exp(value)", "kotlin.math.exp")) public fun exp(value: Double): Double + @Deprecated("Use maxOf or kotlin.math.max instead") public fun max(vararg values: Int): Int + @Deprecated("Use maxOf or kotlin.math.max instead") public fun max(vararg values: Float): Float + @Deprecated("Use maxOf or kotlin.math.max instead") public fun max(vararg values: Double): Double + @Deprecated("Use minOf or kotlin.math.min instead") public fun min(vararg values: Int): Int + @Deprecated("Use minOf or kotlin.math.min instead") public fun min(vararg values: Float): Float + @Deprecated("Use minOf or kotlin.math.min instead") public fun min(vararg values: Double): Double + @Deprecated("Use kotlin.math.sqrt instead.", ReplaceWith("sqrt(value)", "kotlin.math.sqrt")) public fun sqrt(value: Double): Double + @Deprecated("Use kotlin.math.tan instead.", ReplaceWith("tan(value)", "kotlin.math.tan")) public fun tan(value: Double): Double + @Deprecated("Use kotlin.math.log instead.", ReplaceWith("log(value)", "kotlin.math.log")) public fun log(value: Double): Double + @Deprecated("Use kotlin.math.pow instead.", ReplaceWith("pow(base, exp)", "kotlin.math.pow")) public fun pow(base: Double, exp: Double): Double + @Deprecated("Use kotlin.math.round instead.", ReplaceWith("round(value)", "kotlin.math.round")) public fun round(value: Number): Int + @Deprecated("Use kotlin.math.floor instead.", ReplaceWith("floor(value)", "kotlin.math.floor")) public fun floor(value: Number): Int + @Deprecated("Use kotlin.math.ceil instead.", ReplaceWith("ceil(value)", "kotlin.math.ceil")) public fun ceil(value: Number): Int @PublishedApi @@ -58,9 +80,13 @@ public external object Math { /** * Returns the smaller of two values. */ +@Suppress("DEPRECATION") +@Deprecated("Use minOf or kotlin.math.min instead", ReplaceWith("minOf(a, b)")) public fun Math.min(a: Long, b: Long): Long = if (a <= b) a else b /** * Returns the greater of two values. */ +@Suppress("DEPRECATION") +@Deprecated("Use maxOf or kotlin.math.max instead", ReplaceWith("maxOf(a, b)")) public fun Math.max(a: Long, b: Long): Long = if (a >= b) a else b diff --git a/js/js.libraries/src/core/kotlin.math.kt b/js/js.libraries/src/core/math.kt similarity index 99% rename from js/js.libraries/src/core/kotlin.math.kt rename to js/js.libraries/src/core/math.kt index e4bb151b11b..0c71f2cab4b 100644 --- a/js/js.libraries/src/core/kotlin.math.kt +++ b/js/js.libraries/src/core/math.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +@file:Suppress("DEPRECATION") package kotlin.math