Skip to content

Commit d70edeb

Browse files
ilya-gAbduqodiri Qurbonzoda
and
Abduqodiri Qurbonzoda
committed
Hide deprecated JS Math object from public API and rename to JsMath
KT-41318 - Rename Math to JsMath and remove unused functions - Fix return types, remove duplicating JsMath from longjs.kt Co-authored-by: Abduqodiri Qurbonzoda <[email protected]>
1 parent d9ab961 commit d70edeb

File tree

10 files changed

+114
-380
lines changed

10 files changed

+114
-380
lines changed

libraries/stdlib/api/js-v1/kotlin.js.kt

-78
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ public inline operator fun kotlin.js.RegExpMatch.get(index: kotlin.Int): kotlin.
4343
@kotlin.internal.DynamicExtension
4444
public operator fun dynamic.iterator(): kotlin.collections.Iterator<dynamic>
4545

46-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead", replaceWith = kotlin.ReplaceWith(expression = "maxOf(a, b)", imports = {}))
47-
public fun kotlin.js.Math.max(a: kotlin.Long, b: kotlin.Long): kotlin.Long
48-
49-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead", replaceWith = kotlin.ReplaceWith(expression = "minOf(a, b)", imports = {}))
50-
public fun kotlin.js.Math.min(a: kotlin.Long, b: kotlin.Long): kotlin.Long
51-
5246
public fun kotlin.js.RegExp.reset(): kotlin.Unit
5347

5448
public inline fun <T, S> kotlin.js.Promise<kotlin.js.Promise<T>>.then(noinline onFulfilled: ((T) -> S)?): kotlin.js.Promise<S>
@@ -276,78 +270,6 @@ public external interface Json {
276270
public abstract operator fun set(propertyName: kotlin.String, value: kotlin.Any?): kotlin.Unit
277271
}
278272

279-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use top-level functions from kotlin.math package instead.")
280-
public external object Math {
281-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.PI instead.", replaceWith = kotlin.ReplaceWith(expression = "PI", imports = {"kotlin.math.PI"}))
282-
public final val PI: kotlin.Double { get; }
283-
284-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.abs instead.", replaceWith = kotlin.ReplaceWith(expression = "abs(value)", imports = {"kotlin.math.abs"}))
285-
public final fun abs(value: kotlin.Double): kotlin.Double
286-
287-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.acos instead.", replaceWith = kotlin.ReplaceWith(expression = "acos(value)", imports = {"kotlin.math.acos"}))
288-
public final fun acos(value: kotlin.Double): kotlin.Double
289-
290-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.asin instead.", replaceWith = kotlin.ReplaceWith(expression = "asin(value)", imports = {"kotlin.math.asin"}))
291-
public final fun asin(value: kotlin.Double): kotlin.Double
292-
293-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.atan instead.", replaceWith = kotlin.ReplaceWith(expression = "atan(value)", imports = {"kotlin.math.atan"}))
294-
public final fun atan(value: kotlin.Double): kotlin.Double
295-
296-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.atan2 instead.", replaceWith = kotlin.ReplaceWith(expression = "atan2(y, x)", imports = {"kotlin.math.atan2"}))
297-
public final fun atan2(y: kotlin.Double, x: kotlin.Double): kotlin.Double
298-
299-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.ceil instead.", replaceWith = kotlin.ReplaceWith(expression = "ceil(value)", imports = {"kotlin.math.ceil"}))
300-
public final fun ceil(value: kotlin.Number): kotlin.Int
301-
302-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.cos instead.", replaceWith = kotlin.ReplaceWith(expression = "cos(value)", imports = {"kotlin.math.cos"}))
303-
public final fun cos(value: kotlin.Double): kotlin.Double
304-
305-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.exp instead.", replaceWith = kotlin.ReplaceWith(expression = "exp(value)", imports = {"kotlin.math.exp"}))
306-
public final fun exp(value: kotlin.Double): kotlin.Double
307-
308-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.floor instead.", replaceWith = kotlin.ReplaceWith(expression = "floor(value)", imports = {"kotlin.math.floor"}))
309-
public final fun floor(value: kotlin.Number): kotlin.Int
310-
311-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.ln instead.", replaceWith = kotlin.ReplaceWith(expression = "ln(value)", imports = {"kotlin.math.ln"}))
312-
public final fun log(value: kotlin.Double): kotlin.Double
313-
314-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
315-
public final fun max(vararg values: kotlin.Double): kotlin.Double
316-
317-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
318-
public final fun max(vararg values: kotlin.Float): kotlin.Float
319-
320-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
321-
public final fun max(vararg values: kotlin.Int): kotlin.Int
322-
323-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
324-
public final fun min(vararg values: kotlin.Double): kotlin.Double
325-
326-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
327-
public final fun min(vararg values: kotlin.Float): kotlin.Float
328-
329-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
330-
public final fun min(vararg values: kotlin.Int): kotlin.Int
331-
332-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.pow instead.", replaceWith = kotlin.ReplaceWith(expression = "base.pow(exp)", imports = {"kotlin.math.pow"}))
333-
public final fun pow(base: kotlin.Double, exp: kotlin.Double): kotlin.Double
334-
335-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use Random.nextDouble instead", replaceWith = kotlin.ReplaceWith(expression = "kotlin.random.Random.nextDouble()", imports = {"kotlin.random.Random"}))
336-
public final fun random(): kotlin.Double
337-
338-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.round instead.", replaceWith = kotlin.ReplaceWith(expression = "round(value)", imports = {"kotlin.math.round"}))
339-
public final fun round(value: kotlin.Number): kotlin.Int
340-
341-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.sin instead.", replaceWith = kotlin.ReplaceWith(expression = "sin(value)", imports = {"kotlin.math.sin"}))
342-
public final fun sin(value: kotlin.Double): kotlin.Double
343-
344-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.sqrt instead.", replaceWith = kotlin.ReplaceWith(expression = "sqrt(value)", imports = {"kotlin.math.sqrt"}))
345-
public final fun sqrt(value: kotlin.Double): kotlin.Double
346-
347-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.tan instead.", replaceWith = kotlin.ReplaceWith(expression = "tan(value)", imports = {"kotlin.math.tan"}))
348-
public final fun tan(value: kotlin.Double): kotlin.Double
349-
}
350-
351273
public open external class Promise<out T> {
352274
public constructor Promise<out T>(executor: (resolve: (T) -> kotlin.Unit, reject: (kotlin.Throwable) -> kotlin.Unit) -> kotlin.Unit)
353275

libraries/stdlib/api/js/kotlin.js.kt

-78
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ public inline operator fun kotlin.js.RegExpMatch.get(index: kotlin.Int): kotlin.
4242
@kotlin.internal.DynamicExtension
4343
public operator fun dynamic.iterator(): kotlin.collections.Iterator<dynamic>
4444

45-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead", replaceWith = kotlin.ReplaceWith(expression = "maxOf(a, b)", imports = {}))
46-
public fun kotlin.js.Math.max(a: kotlin.Long, b: kotlin.Long): kotlin.Long
47-
48-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead", replaceWith = kotlin.ReplaceWith(expression = "minOf(a, b)", imports = {}))
49-
public fun kotlin.js.Math.min(a: kotlin.Long, b: kotlin.Long): kotlin.Long
50-
5145
public fun kotlin.js.RegExp.reset(): kotlin.Unit
5246

5347
public inline fun <T, S> kotlin.js.Promise<kotlin.js.Promise<T>>.then(noinline onFulfilled: ((T) -> S)?): kotlin.js.Promise<S>
@@ -275,78 +269,6 @@ public external interface Json {
275269
public abstract operator fun set(propertyName: kotlin.String, value: kotlin.Any?): kotlin.Unit
276270
}
277271

278-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use top-level functions from kotlin.math package instead.")
279-
public external object Math {
280-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.PI instead.", replaceWith = kotlin.ReplaceWith(expression = "PI", imports = {"kotlin.math.PI"}))
281-
public final val PI: kotlin.Double { get; }
282-
283-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.abs instead.", replaceWith = kotlin.ReplaceWith(expression = "abs(value)", imports = {"kotlin.math.abs"}))
284-
public final fun abs(value: kotlin.Double): kotlin.Double
285-
286-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.acos instead.", replaceWith = kotlin.ReplaceWith(expression = "acos(value)", imports = {"kotlin.math.acos"}))
287-
public final fun acos(value: kotlin.Double): kotlin.Double
288-
289-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.asin instead.", replaceWith = kotlin.ReplaceWith(expression = "asin(value)", imports = {"kotlin.math.asin"}))
290-
public final fun asin(value: kotlin.Double): kotlin.Double
291-
292-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.atan instead.", replaceWith = kotlin.ReplaceWith(expression = "atan(value)", imports = {"kotlin.math.atan"}))
293-
public final fun atan(value: kotlin.Double): kotlin.Double
294-
295-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.atan2 instead.", replaceWith = kotlin.ReplaceWith(expression = "atan2(y, x)", imports = {"kotlin.math.atan2"}))
296-
public final fun atan2(y: kotlin.Double, x: kotlin.Double): kotlin.Double
297-
298-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.ceil instead.", replaceWith = kotlin.ReplaceWith(expression = "ceil(value)", imports = {"kotlin.math.ceil"}))
299-
public final fun ceil(value: kotlin.Number): kotlin.Int
300-
301-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.cos instead.", replaceWith = kotlin.ReplaceWith(expression = "cos(value)", imports = {"kotlin.math.cos"}))
302-
public final fun cos(value: kotlin.Double): kotlin.Double
303-
304-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.exp instead.", replaceWith = kotlin.ReplaceWith(expression = "exp(value)", imports = {"kotlin.math.exp"}))
305-
public final fun exp(value: kotlin.Double): kotlin.Double
306-
307-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.floor instead.", replaceWith = kotlin.ReplaceWith(expression = "floor(value)", imports = {"kotlin.math.floor"}))
308-
public final fun floor(value: kotlin.Number): kotlin.Int
309-
310-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.ln instead.", replaceWith = kotlin.ReplaceWith(expression = "ln(value)", imports = {"kotlin.math.ln"}))
311-
public final fun log(value: kotlin.Double): kotlin.Double
312-
313-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
314-
public final fun max(vararg values: kotlin.Double): kotlin.Double
315-
316-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
317-
public final fun max(vararg values: kotlin.Float): kotlin.Float
318-
319-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use maxOf or kotlin.math.max instead")
320-
public final fun max(vararg values: kotlin.Int): kotlin.Int
321-
322-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
323-
public final fun min(vararg values: kotlin.Double): kotlin.Double
324-
325-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
326-
public final fun min(vararg values: kotlin.Float): kotlin.Float
327-
328-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use minOf or kotlin.math.min instead")
329-
public final fun min(vararg values: kotlin.Int): kotlin.Int
330-
331-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.pow instead.", replaceWith = kotlin.ReplaceWith(expression = "base.pow(exp)", imports = {"kotlin.math.pow"}))
332-
public final fun pow(base: kotlin.Double, exp: kotlin.Double): kotlin.Double
333-
334-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use Random.nextDouble instead", replaceWith = kotlin.ReplaceWith(expression = "kotlin.random.Random.nextDouble()", imports = {"kotlin.random.Random"}))
335-
public final fun random(): kotlin.Double
336-
337-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.round instead.", replaceWith = kotlin.ReplaceWith(expression = "round(value)", imports = {"kotlin.math.round"}))
338-
public final fun round(value: kotlin.Number): kotlin.Int
339-
340-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.sin instead.", replaceWith = kotlin.ReplaceWith(expression = "sin(value)", imports = {"kotlin.math.sin"}))
341-
public final fun sin(value: kotlin.Double): kotlin.Double
342-
343-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.sqrt instead.", replaceWith = kotlin.ReplaceWith(expression = "sqrt(value)", imports = {"kotlin.math.sqrt"}))
344-
public final fun sqrt(value: kotlin.Double): kotlin.Double
345-
346-
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "Use kotlin.math.tan instead.", replaceWith = kotlin.ReplaceWith(expression = "tan(value)", imports = {"kotlin.math.tan"}))
347-
public final fun tan(value: kotlin.Double): kotlin.Double
348-
}
349-
350272
public open external class Promise<out T> {
351273
public constructor Promise<out T>(executor: (resolve: (T) -> kotlin.Unit, reject: (kotlin.Throwable) -> kotlin.Unit) -> kotlin.Unit)
352274

libraries/stdlib/js-ir/runtime/longjs.kt

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/*
2-
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
2+
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
44
*/
55

6-
76
// Copyright 2009 The Closure Library Authors. All Rights Reserved.
87
//
98
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -259,7 +258,7 @@ internal fun Long.divide(other: Long): Long {
259258
// We will tweak the approximate result by changing it in the 48-th digit or
260259
// the smallest non-fractional digit, whichever is larger.
261260
val log2 = JsMath.ceil(JsMath.log(approx2) / JsMath.LN2)
262-
val delta = if (log2 <= 48) 1.0 else JsMath.pow(2, log2 - 48)
261+
val delta = if (log2 <= 48) 1.0 else JsMath.pow(2.0, log2 - 48)
263262

264263
// Decrease the approximation until it is smaller than the remainder. Note
265264
// that if it is too large, the product overflows and is negative.
@@ -386,13 +385,4 @@ private val MIN_VALUE = Long(0, 1 shl 31)
386385

387386
private val TWO_PWR_24_ = fromInt(1 shl 24)
388387

389-
@JsName("Math")
390-
internal external object JsMath {
391-
fun max(lhs: Number, rhs: Number): Double
392-
fun floor(x: Number): Double
393-
fun ceil(x: Number): Double
394-
fun log(x: Number): Double
395-
fun pow(base: Number, exponent: Number): Double
396-
val LN2: Double
397-
}
398388

0 commit comments

Comments
 (0)