Raise deprecation level for kotlin.js.Math functions
#KT-21703
This commit is contained in:
@@ -29,6 +29,7 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T): T {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
@@ -38,6 +39,7 @@ public actual inline fun maxOf(a: Byte, b: Byte): Byte {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Short, b: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
@@ -47,6 +49,7 @@ public actual inline fun maxOf(a: Short, b: Short): Short {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Int, b: Int): Int {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
@@ -55,7 +58,7 @@ public actual inline fun maxOf(a: Int, b: Int): Int {
|
||||
* Returns the greater of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
|
||||
public actual inline fun maxOf(a: Long, b: Long): Long {
|
||||
return if (a >= b) a else b
|
||||
}
|
||||
@@ -65,6 +68,7 @@ public actual inline fun maxOf(a: Long, b: Long): Long {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Float, b: Float): Float {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
@@ -74,6 +78,7 @@ public actual inline fun maxOf(a: Float, b: Float): Float {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Double, b: Double): Double {
|
||||
return Math.max(a, b)
|
||||
}
|
||||
@@ -91,6 +96,7 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
@@ -100,6 +106,7 @@ public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
@@ -109,6 +116,7 @@ public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
@@ -127,6 +135,7 @@ public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
@@ -136,6 +145,7 @@ public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.max(a, b, c)
|
||||
}
|
||||
@@ -154,6 +164,7 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T): T {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
@@ -163,6 +174,7 @@ public actual inline fun minOf(a: Byte, b: Byte): Byte {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Short, b: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
@@ -172,6 +184,7 @@ public actual inline fun minOf(a: Short, b: Short): Short {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Int, b: Int): Int {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
@@ -180,7 +193,7 @@ public actual inline fun minOf(a: Int, b: Int): Int {
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
|
||||
public actual inline fun minOf(a: Long, b: Long): Long {
|
||||
return if (a <= b) a else b
|
||||
}
|
||||
@@ -190,6 +203,7 @@ public actual inline fun minOf(a: Long, b: Long): Long {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Float, b: Float): Float {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
@@ -199,6 +213,7 @@ public actual inline fun minOf(a: Float, b: Float): Float {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Double, b: Double): Double {
|
||||
return Math.min(a, b)
|
||||
}
|
||||
@@ -216,6 +231,7 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
|
||||
}
|
||||
@@ -225,6 +241,7 @@ public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
|
||||
}
|
||||
@@ -234,6 +251,7 @@ public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
@@ -252,6 +270,7 @@ public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
@@ -261,6 +280,7 @@ public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
|
||||
*/
|
||||
@SinceKotlin("1.1")
|
||||
@kotlin.internal.InlineOnly
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
|
||||
return Math.min(a, b, c)
|
||||
}
|
||||
|
||||
@@ -8,53 +8,53 @@ package kotlin.js
|
||||
/**
|
||||
* 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.")
|
||||
@Deprecated("Use top-level functions from kotlin.math package instead.", level = DeprecationLevel.WARNING)
|
||||
public external object Math {
|
||||
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"))
|
||||
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"), level = DeprecationLevel.ERROR)
|
||||
public val PI: Double
|
||||
@Deprecated("Use Random.nextDouble instead", ReplaceWith("kotlin.random.Random.nextDouble()", "kotlin.random.Random"))
|
||||
@Deprecated("Use Random.nextDouble instead", ReplaceWith("kotlin.random.Random.nextDouble()", "kotlin.random.Random"), level = DeprecationLevel.WARNING)
|
||||
public fun random(): Double
|
||||
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"))
|
||||
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"), level = DeprecationLevel.ERROR)
|
||||
public fun abs(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.acos instead.", ReplaceWith("acos(value)", "kotlin.math.acos"))
|
||||
@Deprecated("Use kotlin.math.acos instead.", ReplaceWith("acos(value)", "kotlin.math.acos"), level = DeprecationLevel.ERROR)
|
||||
public fun acos(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.asin instead.", ReplaceWith("asin(value)", "kotlin.math.asin"))
|
||||
@Deprecated("Use kotlin.math.asin instead.", ReplaceWith("asin(value)", "kotlin.math.asin"), level = DeprecationLevel.ERROR)
|
||||
public fun asin(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.atan instead.", ReplaceWith("atan(value)", "kotlin.math.atan"))
|
||||
@Deprecated("Use kotlin.math.atan instead.", ReplaceWith("atan(value)", "kotlin.math.atan"), level = DeprecationLevel.ERROR)
|
||||
public fun atan(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.atan2 instead.", ReplaceWith("atan2(y, x)", "kotlin.math.atan2"))
|
||||
@Deprecated("Use kotlin.math.atan2 instead.", ReplaceWith("atan2(y, x)", "kotlin.math.atan2"), level = DeprecationLevel.ERROR)
|
||||
public fun atan2(y: Double, x: Double): Double
|
||||
@Deprecated("Use kotlin.math.cos instead.", ReplaceWith("cos(value)", "kotlin.math.cos"))
|
||||
@Deprecated("Use kotlin.math.cos instead.", ReplaceWith("cos(value)", "kotlin.math.cos"), level = DeprecationLevel.ERROR)
|
||||
public fun cos(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.sin instead.", ReplaceWith("sin(value)", "kotlin.math.sin"))
|
||||
@Deprecated("Use kotlin.math.sin instead.", ReplaceWith("sin(value)", "kotlin.math.sin"), level = DeprecationLevel.ERROR)
|
||||
public fun sin(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.exp instead.", ReplaceWith("exp(value)", "kotlin.math.exp"))
|
||||
@Deprecated("Use kotlin.math.exp instead.", ReplaceWith("exp(value)", "kotlin.math.exp"), level = DeprecationLevel.ERROR)
|
||||
public fun exp(value: Double): Double
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead")
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
|
||||
public fun max(vararg values: Int): Int
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead")
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
|
||||
public fun max(vararg values: Float): Float
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead")
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
|
||||
public fun max(vararg values: Double): Double
|
||||
@Deprecated("Use minOf or kotlin.math.min instead")
|
||||
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
|
||||
public fun min(vararg values: Int): Int
|
||||
@Deprecated("Use minOf or kotlin.math.min instead")
|
||||
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
|
||||
public fun min(vararg values: Float): Float
|
||||
@Deprecated("Use minOf or kotlin.math.min instead")
|
||||
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
|
||||
public fun min(vararg values: Double): Double
|
||||
@Deprecated("Use kotlin.math.sqrt instead.", ReplaceWith("sqrt(value)", "kotlin.math.sqrt"))
|
||||
@Deprecated("Use kotlin.math.sqrt instead.", ReplaceWith("sqrt(value)", "kotlin.math.sqrt"), level = DeprecationLevel.ERROR)
|
||||
public fun sqrt(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.tan instead.", ReplaceWith("tan(value)", "kotlin.math.tan"))
|
||||
@Deprecated("Use kotlin.math.tan instead.", ReplaceWith("tan(value)", "kotlin.math.tan"), level = DeprecationLevel.ERROR)
|
||||
public fun tan(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.log instead.", ReplaceWith("log(value)", "kotlin.math.log"))
|
||||
@Deprecated("Use kotlin.math.log instead.", ReplaceWith("log(value)", "kotlin.math.log"), level = DeprecationLevel.ERROR)
|
||||
public fun log(value: Double): Double
|
||||
@Deprecated("Use kotlin.math.pow instead.", ReplaceWith("pow(base, exp)", "kotlin.math.pow"))
|
||||
@Deprecated("Use kotlin.math.pow instead.", ReplaceWith("pow(base, exp)", "kotlin.math.pow"), level = DeprecationLevel.ERROR)
|
||||
public fun pow(base: Double, exp: Double): Double
|
||||
@Deprecated("Use kotlin.math.round instead.", ReplaceWith("round(value)", "kotlin.math.round"))
|
||||
@Deprecated("Use kotlin.math.round instead.", ReplaceWith("round(value)", "kotlin.math.round"), level = DeprecationLevel.ERROR)
|
||||
public fun round(value: Number): Int
|
||||
@Deprecated("Use kotlin.math.floor instead.", ReplaceWith("floor(value)", "kotlin.math.floor"))
|
||||
@Deprecated("Use kotlin.math.floor instead.", ReplaceWith("floor(value)", "kotlin.math.floor"), level = DeprecationLevel.ERROR)
|
||||
public fun floor(value: Number): Int
|
||||
@Deprecated("Use kotlin.math.ceil instead.", ReplaceWith("ceil(value)", "kotlin.math.ceil"))
|
||||
@Deprecated("Use kotlin.math.ceil instead.", ReplaceWith("ceil(value)", "kotlin.math.ceil"), level = DeprecationLevel.ERROR)
|
||||
public fun ceil(value: Number): Int
|
||||
|
||||
@PublishedApi
|
||||
@@ -93,12 +93,12 @@ public external object Math {
|
||||
* Returns the smaller of two values.
|
||||
*/
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Use minOf or kotlin.math.min instead", ReplaceWith("minOf(a, b)"))
|
||||
@Deprecated("Use minOf or kotlin.math.min instead", ReplaceWith("minOf(a, b)"), level = DeprecationLevel.ERROR)
|
||||
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)"))
|
||||
@Deprecated("Use maxOf or kotlin.math.max instead", ReplaceWith("maxOf(a, b)"), level = DeprecationLevel.ERROR)
|
||||
public fun Math.max(a: Long, b: Long): Long = if (a >= b) a else b
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 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:Suppress("DEPRECATION")
|
||||
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
|
||||
package kotlin.math
|
||||
|
||||
|
||||
|
||||
@@ -153,6 +153,7 @@ object ComparableOps : TemplateGroupBase() {
|
||||
}
|
||||
var convertBack = "to$primitive()"
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
convertBack = "unsafeCast<$primitive>()"
|
||||
}
|
||||
body {
|
||||
@@ -198,11 +199,13 @@ object ComparableOps : TemplateGroupBase() {
|
||||
if (primitive in shortIntPrimitives) {
|
||||
body { "return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).to$primitive()" }
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
body { "return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<$primitive>()" }
|
||||
}
|
||||
}
|
||||
else if (primitive != PrimitiveType.Long) {
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
body { "return Math.min(a, b, c)" }
|
||||
}
|
||||
}
|
||||
@@ -267,6 +270,7 @@ object ComparableOps : TemplateGroupBase() {
|
||||
}
|
||||
var convertBack = "to$primitive()"
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
convertBack = "unsafeCast<$primitive>()"
|
||||
}
|
||||
body {
|
||||
@@ -312,11 +316,13 @@ object ComparableOps : TemplateGroupBase() {
|
||||
if (primitive in shortIntPrimitives) {
|
||||
body { "return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).to$primitive()" }
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
body { "return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<$primitive>()" }
|
||||
}
|
||||
}
|
||||
else if (primitive != PrimitiveType.Long) {
|
||||
on(Platform.JS) {
|
||||
suppress("DEPRECATION_ERROR")
|
||||
body { "return Math.max(a, b, c)" }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user