Skip to content

Commit 010b36b

Browse files
committed
Raise deprecation level for kotlin.js.Math functions
#KT-21703
1 parent fbd2322 commit 010b36b

File tree

4 files changed

+55
-29
lines changed

4 files changed

+55
-29
lines changed

libraries/stdlib/js/src/generated/_ComparisonsJs.kt

+22-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T): T {
2929
*/
3030
@SinceKotlin("1.1")
3131
@kotlin.internal.InlineOnly
32+
@Suppress("DEPRECATION_ERROR")
3233
public actual inline fun maxOf(a: Byte, b: Byte): Byte {
3334
return Math.max(a.toInt(), b.toInt()).unsafeCast<Byte>()
3435
}
@@ -38,6 +39,7 @@ public actual inline fun maxOf(a: Byte, b: Byte): Byte {
3839
*/
3940
@SinceKotlin("1.1")
4041
@kotlin.internal.InlineOnly
42+
@Suppress("DEPRECATION_ERROR")
4143
public actual inline fun maxOf(a: Short, b: Short): Short {
4244
return Math.max(a.toInt(), b.toInt()).unsafeCast<Short>()
4345
}
@@ -47,6 +49,7 @@ public actual inline fun maxOf(a: Short, b: Short): Short {
4749
*/
4850
@SinceKotlin("1.1")
4951
@kotlin.internal.InlineOnly
52+
@Suppress("DEPRECATION_ERROR")
5053
public actual inline fun maxOf(a: Int, b: Int): Int {
5154
return Math.max(a, b)
5255
}
@@ -55,7 +58,7 @@ public actual inline fun maxOf(a: Int, b: Int): Int {
5558
* Returns the greater of two values.
5659
*/
5760
@SinceKotlin("1.1")
58-
@Suppress("NOTHING_TO_INLINE")
61+
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
5962
public actual inline fun maxOf(a: Long, b: Long): Long {
6063
return if (a >= b) a else b
6164
}
@@ -65,6 +68,7 @@ public actual inline fun maxOf(a: Long, b: Long): Long {
6568
*/
6669
@SinceKotlin("1.1")
6770
@kotlin.internal.InlineOnly
71+
@Suppress("DEPRECATION_ERROR")
6872
public actual inline fun maxOf(a: Float, b: Float): Float {
6973
return Math.max(a, b)
7074
}
@@ -74,6 +78,7 @@ public actual inline fun maxOf(a: Float, b: Float): Float {
7478
*/
7579
@SinceKotlin("1.1")
7680
@kotlin.internal.InlineOnly
81+
@Suppress("DEPRECATION_ERROR")
7782
public actual inline fun maxOf(a: Double, b: Double): Double {
7883
return Math.max(a, b)
7984
}
@@ -91,6 +96,7 @@ public actual fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T {
9196
*/
9297
@SinceKotlin("1.1")
9398
@kotlin.internal.InlineOnly
99+
@Suppress("DEPRECATION_ERROR")
94100
public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
95101
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
96102
}
@@ -100,6 +106,7 @@ public actual inline fun maxOf(a: Byte, b: Byte, c: Byte): Byte {
100106
*/
101107
@SinceKotlin("1.1")
102108
@kotlin.internal.InlineOnly
109+
@Suppress("DEPRECATION_ERROR")
103110
public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
104111
return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
105112
}
@@ -109,6 +116,7 @@ public actual inline fun maxOf(a: Short, b: Short, c: Short): Short {
109116
*/
110117
@SinceKotlin("1.1")
111118
@kotlin.internal.InlineOnly
119+
@Suppress("DEPRECATION_ERROR")
112120
public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
113121
return Math.max(a, b, c)
114122
}
@@ -127,6 +135,7 @@ public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
127135
*/
128136
@SinceKotlin("1.1")
129137
@kotlin.internal.InlineOnly
138+
@Suppress("DEPRECATION_ERROR")
130139
public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
131140
return Math.max(a, b, c)
132141
}
@@ -136,6 +145,7 @@ public actual inline fun maxOf(a: Float, b: Float, c: Float): Float {
136145
*/
137146
@SinceKotlin("1.1")
138147
@kotlin.internal.InlineOnly
148+
@Suppress("DEPRECATION_ERROR")
139149
public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
140150
return Math.max(a, b, c)
141151
}
@@ -154,6 +164,7 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T): T {
154164
*/
155165
@SinceKotlin("1.1")
156166
@kotlin.internal.InlineOnly
167+
@Suppress("DEPRECATION_ERROR")
157168
public actual inline fun minOf(a: Byte, b: Byte): Byte {
158169
return Math.min(a.toInt(), b.toInt()).unsafeCast<Byte>()
159170
}
@@ -163,6 +174,7 @@ public actual inline fun minOf(a: Byte, b: Byte): Byte {
163174
*/
164175
@SinceKotlin("1.1")
165176
@kotlin.internal.InlineOnly
177+
@Suppress("DEPRECATION_ERROR")
166178
public actual inline fun minOf(a: Short, b: Short): Short {
167179
return Math.min(a.toInt(), b.toInt()).unsafeCast<Short>()
168180
}
@@ -172,6 +184,7 @@ public actual inline fun minOf(a: Short, b: Short): Short {
172184
*/
173185
@SinceKotlin("1.1")
174186
@kotlin.internal.InlineOnly
187+
@Suppress("DEPRECATION_ERROR")
175188
public actual inline fun minOf(a: Int, b: Int): Int {
176189
return Math.min(a, b)
177190
}
@@ -180,7 +193,7 @@ public actual inline fun minOf(a: Int, b: Int): Int {
180193
* Returns the smaller of two values.
181194
*/
182195
@SinceKotlin("1.1")
183-
@Suppress("NOTHING_TO_INLINE")
196+
@Suppress("DEPRECATION_ERROR", "NOTHING_TO_INLINE")
184197
public actual inline fun minOf(a: Long, b: Long): Long {
185198
return if (a <= b) a else b
186199
}
@@ -190,6 +203,7 @@ public actual inline fun minOf(a: Long, b: Long): Long {
190203
*/
191204
@SinceKotlin("1.1")
192205
@kotlin.internal.InlineOnly
206+
@Suppress("DEPRECATION_ERROR")
193207
public actual inline fun minOf(a: Float, b: Float): Float {
194208
return Math.min(a, b)
195209
}
@@ -199,6 +213,7 @@ public actual inline fun minOf(a: Float, b: Float): Float {
199213
*/
200214
@SinceKotlin("1.1")
201215
@kotlin.internal.InlineOnly
216+
@Suppress("DEPRECATION_ERROR")
202217
public actual inline fun minOf(a: Double, b: Double): Double {
203218
return Math.min(a, b)
204219
}
@@ -216,6 +231,7 @@ public actual fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T {
216231
*/
217232
@SinceKotlin("1.1")
218233
@kotlin.internal.InlineOnly
234+
@Suppress("DEPRECATION_ERROR")
219235
public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
220236
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Byte>()
221237
}
@@ -225,6 +241,7 @@ public actual inline fun minOf(a: Byte, b: Byte, c: Byte): Byte {
225241
*/
226242
@SinceKotlin("1.1")
227243
@kotlin.internal.InlineOnly
244+
@Suppress("DEPRECATION_ERROR")
228245
public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
229246
return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<Short>()
230247
}
@@ -234,6 +251,7 @@ public actual inline fun minOf(a: Short, b: Short, c: Short): Short {
234251
*/
235252
@SinceKotlin("1.1")
236253
@kotlin.internal.InlineOnly
254+
@Suppress("DEPRECATION_ERROR")
237255
public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
238256
return Math.min(a, b, c)
239257
}
@@ -252,6 +270,7 @@ public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
252270
*/
253271
@SinceKotlin("1.1")
254272
@kotlin.internal.InlineOnly
273+
@Suppress("DEPRECATION_ERROR")
255274
public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
256275
return Math.min(a, b, c)
257276
}
@@ -261,6 +280,7 @@ public actual inline fun minOf(a: Float, b: Float, c: Float): Float {
261280
*/
262281
@SinceKotlin("1.1")
263282
@kotlin.internal.InlineOnly
283+
@Suppress("DEPRECATION_ERROR")
264284
public actual inline fun minOf(a: Double, b: Double, c: Double): Double {
265285
return Math.min(a, b, c)
266286
}

libraries/stdlib/js/src/kotlin/js.math.kt

+26-26
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,53 @@ package kotlin.js
88
/**
99
* Exposes the JavaScript [Math object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Math) to Kotlin.
1010
*/
11-
@Deprecated("Use top-level functions from kotlin.math package instead.")
11+
@Deprecated("Use top-level functions from kotlin.math package instead.", level = DeprecationLevel.WARNING)
1212
public external object Math {
13-
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"))
13+
@Deprecated("Use kotlin.math.PI instead.", ReplaceWith("PI", "kotlin.math.PI"), level = DeprecationLevel.ERROR)
1414
public val PI: Double
15-
@Deprecated("Use Random.nextDouble instead", ReplaceWith("kotlin.random.Random.nextDouble()", "kotlin.random.Random"))
15+
@Deprecated("Use Random.nextDouble instead", ReplaceWith("kotlin.random.Random.nextDouble()", "kotlin.random.Random"), level = DeprecationLevel.WARNING)
1616
public fun random(): Double
17-
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"))
17+
@Deprecated("Use kotlin.math.abs instead.", ReplaceWith("abs(value)", "kotlin.math.abs"), level = DeprecationLevel.ERROR)
1818
public fun abs(value: Double): Double
19-
@Deprecated("Use kotlin.math.acos instead.", ReplaceWith("acos(value)", "kotlin.math.acos"))
19+
@Deprecated("Use kotlin.math.acos instead.", ReplaceWith("acos(value)", "kotlin.math.acos"), level = DeprecationLevel.ERROR)
2020
public fun acos(value: Double): Double
21-
@Deprecated("Use kotlin.math.asin instead.", ReplaceWith("asin(value)", "kotlin.math.asin"))
21+
@Deprecated("Use kotlin.math.asin instead.", ReplaceWith("asin(value)", "kotlin.math.asin"), level = DeprecationLevel.ERROR)
2222
public fun asin(value: Double): Double
23-
@Deprecated("Use kotlin.math.atan instead.", ReplaceWith("atan(value)", "kotlin.math.atan"))
23+
@Deprecated("Use kotlin.math.atan instead.", ReplaceWith("atan(value)", "kotlin.math.atan"), level = DeprecationLevel.ERROR)
2424
public fun atan(value: Double): Double
25-
@Deprecated("Use kotlin.math.atan2 instead.", ReplaceWith("atan2(y, x)", "kotlin.math.atan2"))
25+
@Deprecated("Use kotlin.math.atan2 instead.", ReplaceWith("atan2(y, x)", "kotlin.math.atan2"), level = DeprecationLevel.ERROR)
2626
public fun atan2(y: Double, x: Double): Double
27-
@Deprecated("Use kotlin.math.cos instead.", ReplaceWith("cos(value)", "kotlin.math.cos"))
27+
@Deprecated("Use kotlin.math.cos instead.", ReplaceWith("cos(value)", "kotlin.math.cos"), level = DeprecationLevel.ERROR)
2828
public fun cos(value: Double): Double
29-
@Deprecated("Use kotlin.math.sin instead.", ReplaceWith("sin(value)", "kotlin.math.sin"))
29+
@Deprecated("Use kotlin.math.sin instead.", ReplaceWith("sin(value)", "kotlin.math.sin"), level = DeprecationLevel.ERROR)
3030
public fun sin(value: Double): Double
31-
@Deprecated("Use kotlin.math.exp instead.", ReplaceWith("exp(value)", "kotlin.math.exp"))
31+
@Deprecated("Use kotlin.math.exp instead.", ReplaceWith("exp(value)", "kotlin.math.exp"), level = DeprecationLevel.ERROR)
3232
public fun exp(value: Double): Double
33-
@Deprecated("Use maxOf or kotlin.math.max instead")
33+
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
3434
public fun max(vararg values: Int): Int
35-
@Deprecated("Use maxOf or kotlin.math.max instead")
35+
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
3636
public fun max(vararg values: Float): Float
37-
@Deprecated("Use maxOf or kotlin.math.max instead")
37+
@Deprecated("Use maxOf or kotlin.math.max instead", level = DeprecationLevel.ERROR)
3838
public fun max(vararg values: Double): Double
39-
@Deprecated("Use minOf or kotlin.math.min instead")
39+
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
4040
public fun min(vararg values: Int): Int
41-
@Deprecated("Use minOf or kotlin.math.min instead")
41+
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
4242
public fun min(vararg values: Float): Float
43-
@Deprecated("Use minOf or kotlin.math.min instead")
43+
@Deprecated("Use minOf or kotlin.math.min instead", level = DeprecationLevel.ERROR)
4444
public fun min(vararg values: Double): Double
45-
@Deprecated("Use kotlin.math.sqrt instead.", ReplaceWith("sqrt(value)", "kotlin.math.sqrt"))
45+
@Deprecated("Use kotlin.math.sqrt instead.", ReplaceWith("sqrt(value)", "kotlin.math.sqrt"), level = DeprecationLevel.ERROR)
4646
public fun sqrt(value: Double): Double
47-
@Deprecated("Use kotlin.math.tan instead.", ReplaceWith("tan(value)", "kotlin.math.tan"))
47+
@Deprecated("Use kotlin.math.tan instead.", ReplaceWith("tan(value)", "kotlin.math.tan"), level = DeprecationLevel.ERROR)
4848
public fun tan(value: Double): Double
49-
@Deprecated("Use kotlin.math.log instead.", ReplaceWith("log(value)", "kotlin.math.log"))
49+
@Deprecated("Use kotlin.math.log instead.", ReplaceWith("log(value)", "kotlin.math.log"), level = DeprecationLevel.ERROR)
5050
public fun log(value: Double): Double
51-
@Deprecated("Use kotlin.math.pow instead.", ReplaceWith("pow(base, exp)", "kotlin.math.pow"))
51+
@Deprecated("Use kotlin.math.pow instead.", ReplaceWith("pow(base, exp)", "kotlin.math.pow"), level = DeprecationLevel.ERROR)
5252
public fun pow(base: Double, exp: Double): Double
53-
@Deprecated("Use kotlin.math.round instead.", ReplaceWith("round(value)", "kotlin.math.round"))
53+
@Deprecated("Use kotlin.math.round instead.", ReplaceWith("round(value)", "kotlin.math.round"), level = DeprecationLevel.ERROR)
5454
public fun round(value: Number): Int
55-
@Deprecated("Use kotlin.math.floor instead.", ReplaceWith("floor(value)", "kotlin.math.floor"))
55+
@Deprecated("Use kotlin.math.floor instead.", ReplaceWith("floor(value)", "kotlin.math.floor"), level = DeprecationLevel.ERROR)
5656
public fun floor(value: Number): Int
57-
@Deprecated("Use kotlin.math.ceil instead.", ReplaceWith("ceil(value)", "kotlin.math.ceil"))
57+
@Deprecated("Use kotlin.math.ceil instead.", ReplaceWith("ceil(value)", "kotlin.math.ceil"), level = DeprecationLevel.ERROR)
5858
public fun ceil(value: Number): Int
5959

6060
@PublishedApi
@@ -93,12 +93,12 @@ public external object Math {
9393
* Returns the smaller of two values.
9494
*/
9595
@Suppress("DEPRECATION")
96-
@Deprecated("Use minOf or kotlin.math.min instead", ReplaceWith("minOf(a, b)"))
96+
@Deprecated("Use minOf or kotlin.math.min instead", ReplaceWith("minOf(a, b)"), level = DeprecationLevel.ERROR)
9797
public fun Math.min(a: Long, b: Long): Long = if (a <= b) a else b
9898

9999
/**
100100
* Returns the greater of two values.
101101
*/
102102
@Suppress("DEPRECATION")
103-
@Deprecated("Use maxOf or kotlin.math.max instead", ReplaceWith("maxOf(a, b)"))
103+
@Deprecated("Use maxOf or kotlin.math.max instead", ReplaceWith("maxOf(a, b)"), level = DeprecationLevel.ERROR)
104104
public fun Math.max(a: Long, b: Long): Long = if (a >= b) a else b

libraries/stdlib/js/src/kotlin/math.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
33
* that can be found in the license/LICENSE.txt file.
44
*/
5-
@file:Suppress("DEPRECATION")
5+
@file:Suppress("DEPRECATION", "DEPRECATION_ERROR")
66
package kotlin.math
77

88

libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ object ComparableOps : TemplateGroupBase() {
153153
}
154154
var convertBack = "to$primitive()"
155155
on(Platform.JS) {
156+
suppress("DEPRECATION_ERROR")
156157
convertBack = "unsafeCast<$primitive>()"
157158
}
158159
body {
@@ -198,11 +199,13 @@ object ComparableOps : TemplateGroupBase() {
198199
if (primitive in shortIntPrimitives) {
199200
body { "return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).to$primitive()" }
200201
on(Platform.JS) {
202+
suppress("DEPRECATION_ERROR")
201203
body { "return Math.min(a.toInt(), b.toInt(), c.toInt()).unsafeCast<$primitive>()" }
202204
}
203205
}
204206
else if (primitive != PrimitiveType.Long) {
205207
on(Platform.JS) {
208+
suppress("DEPRECATION_ERROR")
206209
body { "return Math.min(a, b, c)" }
207210
}
208211
}
@@ -267,6 +270,7 @@ object ComparableOps : TemplateGroupBase() {
267270
}
268271
var convertBack = "to$primitive()"
269272
on(Platform.JS) {
273+
suppress("DEPRECATION_ERROR")
270274
convertBack = "unsafeCast<$primitive>()"
271275
}
272276
body {
@@ -312,11 +316,13 @@ object ComparableOps : TemplateGroupBase() {
312316
if (primitive in shortIntPrimitives) {
313317
body { "return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).to$primitive()" }
314318
on(Platform.JS) {
319+
suppress("DEPRECATION_ERROR")
315320
body { "return Math.max(a.toInt(), b.toInt(), c.toInt()).unsafeCast<$primitive>()" }
316321
}
317322
}
318323
else if (primitive != PrimitiveType.Long) {
319324
on(Platform.JS) {
325+
suppress("DEPRECATION_ERROR")
320326
body { "return Math.max(a, b, c)" }
321327
}
322328
}

0 commit comments

Comments
 (0)