Skip to content

Commit eb980c8

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 (cherry picked from commit 1f2a8eb)
1 parent f69011c commit eb980c8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ internal object PrimitiveClasses {
3232
val intClass = PrimitiveKClassImpl(js("Number").unsafeCast<JsClass<Int>>(), "Int", { it is Int })
3333

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

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

0 commit comments

Comments
 (0)