Skip to content

Commit 1f2a8eb

Browse files
broadwaylambSpace Team
authored andcommitted
[JS stdlib] Add a safeguard for BigInt class for pre-ES2020 engines
Without this, this code would throw the `ReferenceError` even when compiling Longs as BigInts is disabled. ^KT-80873 Fixed
1 parent e663973 commit 1f2a8eb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libraries/stdlib/js/src/kotlin/reflect/primitives.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package kotlin.reflect.js.internal
77

88
import kotlin.internal.UsedFromCompilerGeneratedCode
9-
import kotlin.js.JsClass
109
import kotlin.js.internal.BigInt
1110

1211
@JsName("PrimitiveClasses")
@@ -34,7 +33,8 @@ internal object PrimitiveClasses {
3433
val intClass = PrimitiveKClassImpl(js("Number").unsafeCast<JsClass<Int>>(), "Int", { it is Int })
3534

3635
@JsName("longClass")
37-
val longClass = PrimitiveKClassImpl(BigInt.unsafeCast<JsClass<Long>>(), "Long", { it is Long })
36+
val longClass =
37+
PrimitiveKClassImpl((if (jsTypeOf(BigInt) == "undefined") VOID else BigInt).unsafeCast<JsClass<Long>>(), "Long", { it is Long })
3838

3939
@JsName("floatClass")
4040
val floatClass = PrimitiveKClassImpl(js("Number").unsafeCast<JsClass<Float>>(), "Float", { it is Float })

0 commit comments

Comments
 (0)