Revert "[JS IR] [runtime] Remove valueOf method from Long"
This reverts commit e13b6b2a90.
The significance of the breakage caused by the removal of `valueOf`
was underestimated.
#KT-50202 Open
This commit is contained in:
@@ -167,6 +167,12 @@ private val expectDeclarationsRemovingPhase = makeDeclarationTransformerPhase(
|
|||||||
description = "Remove expect declaration from module fragment"
|
description = "Remove expect declaration from module fragment"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val stringConcatenationLoweringPhase = makeJsModulePhase(
|
||||||
|
::JsStringConcatenationLowering,
|
||||||
|
name = "JsStringConcatenationLowering",
|
||||||
|
description = "Call toString() for values of some types when concatenating strings"
|
||||||
|
).toModuleLowering()
|
||||||
|
|
||||||
private val lateinitNullableFieldsPhase = makeDeclarationTransformerPhase(
|
private val lateinitNullableFieldsPhase = makeDeclarationTransformerPhase(
|
||||||
::NullableFieldsForLateinitCreationLowering,
|
::NullableFieldsForLateinitCreationLowering,
|
||||||
name = "LateinitNullableFields",
|
name = "LateinitNullableFields",
|
||||||
@@ -835,6 +841,7 @@ val loweringList = listOf<Lowering>(
|
|||||||
copyInlineFunctionBodyLoweringPhase,
|
copyInlineFunctionBodyLoweringPhase,
|
||||||
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase,
|
removeInlineDeclarationsWithReifiedTypeParametersLoweringPhase,
|
||||||
createScriptFunctionsPhase,
|
createScriptFunctionsPhase,
|
||||||
|
stringConcatenationLoweringPhase,
|
||||||
callableReferenceLowering,
|
callableReferenceLowering,
|
||||||
singleAbstractMethodPhase,
|
singleAbstractMethodPhase,
|
||||||
tailrecLoweringPhase,
|
tailrecLoweringPhase,
|
||||||
|
|||||||
+89
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.ir.backend.js.lower
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||||
|
import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
|
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||||
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
|
|
||||||
|
class JsStringConcatenationLowering(val context: CommonBackendContext) : FileLoweringPass {
|
||||||
|
override fun lower(irFile: IrFile) {
|
||||||
|
irFile.transformChildrenVoid(JsStringConcatenationTransformer(context))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class JsStringConcatenationTransformer(val context: CommonBackendContext) : IrElementTransformerVoid() {
|
||||||
|
|
||||||
|
private val IrType.shouldExplicitlyConvertToString: Boolean
|
||||||
|
get() {
|
||||||
|
// If the type is Long or a supertype of Long, we want to call toString() on values of that type.
|
||||||
|
// See KT-39891
|
||||||
|
if (this !is IrSimpleType) return false
|
||||||
|
return when (classifier.signature) {
|
||||||
|
IdSignatureValues.any, IdSignatureValues.comparable, IdSignatureValues.number, IdSignatureValues._long -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun IrExpression.explicitlyConvertedToString(): IrExpression {
|
||||||
|
assert(type.shouldExplicitlyConvertToString)
|
||||||
|
|
||||||
|
return if (type.isNullable()) {
|
||||||
|
JsIrBuilder.buildCall(context.ir.symbols.extensionToString).apply {
|
||||||
|
extensionReceiver = this@explicitlyConvertedToString
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JsIrBuilder.buildCall(context.ir.symbols.memberToString).apply {
|
||||||
|
dispatchReceiver = this@explicitlyConvertedToString
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val IrFunctionSymbol.isStringPlus: Boolean
|
||||||
|
get() = context.ir.symbols.isStringPlus(this)
|
||||||
|
|
||||||
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
|
fun explicitlyConvertToStringIfNeeded(): IrExpression {
|
||||||
|
val lastArgIndex = expression.valueArgumentsCount - 1
|
||||||
|
val plusArg = expression.getValueArgument(lastArgIndex) ?: return super.visitCall(expression)
|
||||||
|
if (!plusArg.type.shouldExplicitlyConvertToString)
|
||||||
|
return super.visitCall(expression)
|
||||||
|
|
||||||
|
expression.putValueArgument(lastArgIndex, plusArg.explicitlyConvertedToString())
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expression.valueArgumentsCount == 0)
|
||||||
|
return super.visitCall(expression)
|
||||||
|
|
||||||
|
if (expression.symbol.isStringPlus)
|
||||||
|
return explicitlyConvertToStringIfNeeded()
|
||||||
|
|
||||||
|
if (expression.dispatchReceiver.safeAs<IrFunctionReference>()?.symbol?.isStringPlus == true)
|
||||||
|
return explicitlyConvertToStringIfNeeded()
|
||||||
|
|
||||||
|
return super.visitCall(expression)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitStringConcatenation(expression: IrStringConcatenation): IrExpression {
|
||||||
|
expression
|
||||||
|
.transformChildrenVoid(object : IrElementTransformerVoid() {
|
||||||
|
override fun visitExpression(expression: IrExpression): IrExpression {
|
||||||
|
if (expression.type.shouldExplicitlyConvertToString)
|
||||||
|
return expression.explicitlyConvertedToString()
|
||||||
|
return expression
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return super.visitStringConcatenation(expression)
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-16
@@ -19,17 +19,17 @@ fun box(): String {
|
|||||||
if (MAX_LONG != "".plus(Long.MAX_VALUE)) return "fail \"\".plus"
|
if (MAX_LONG != "".plus(Long.MAX_VALUE)) return "fail \"\".plus"
|
||||||
if (MAX_LONG != ("" as String?).plus(Long.MAX_VALUE)) return "fail \"\"?.plus"
|
if (MAX_LONG != ("" as String?).plus(Long.MAX_VALUE)) return "fail \"\"?.plus"
|
||||||
if (MAX_LONG != (String::plus)("", Long.MAX_VALUE)) return "fail String::plus"
|
if (MAX_LONG != (String::plus)("", Long.MAX_VALUE)) return "fail String::plus"
|
||||||
if (MAX_LONG != stringPlus("", Long.MAX_VALUE)) return "fail stringPlus(\"\", Long.MAX_VALUE)"
|
// if (MAX_LONG != stringPlus("", Long.MAX_VALUE)) return "fail stringPlus(\"\", Long.MAX_VALUE)"
|
||||||
if (MAX_LONG != customToString("", Long.MAX_VALUE, String::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String::plus)"
|
// if (MAX_LONG != customToString("", Long.MAX_VALUE, String::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String::plus)"
|
||||||
if (MAX_LONG != (String?::plus)("", Long.MAX_VALUE)) return "fail String?::plus"
|
if (MAX_LONG != (String?::plus)("", Long.MAX_VALUE)) return "fail String?::plus"
|
||||||
if (MAX_LONG != stringNPlus("", Long.MAX_VALUE)) return "fail stringNPlus(\"\", Long.MAX_VALUE)"
|
// if (MAX_LONG != stringNPlus("", Long.MAX_VALUE)) return "fail stringNPlus(\"\", Long.MAX_VALUE)"
|
||||||
if (MAX_LONG != customToString("", Long.MAX_VALUE, String?::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String?::plus)"
|
// if (MAX_LONG != customToString("", Long.MAX_VALUE, String?::plus)) return "fail customToString(\"\", Long.MAX_VALUE, String?::plus)"
|
||||||
if (MAX_LONG != (""::plus)(Long.MAX_VALUE)) return "fail \"\"::plus"
|
if (MAX_LONG != (""::plus)(Long.MAX_VALUE)) return "fail \"\"::plus"
|
||||||
if (MAX_LONG != emptyStringPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)"
|
// if (MAX_LONG != emptyStringPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)"
|
||||||
if (MAX_LONG != customToString(Long.MAX_VALUE, ""::plus)) return "fail customToString(Long.MAX_VALUE, \"\"::plus)"
|
// if (MAX_LONG != customToString(Long.MAX_VALUE, ""::plus)) return "fail customToString(Long.MAX_VALUE, \"\"::plus)"
|
||||||
if (MAX_LONG != (("" as String?)::plus)(Long.MAX_VALUE)) return "fail \"\"?::plus"
|
if (MAX_LONG != (("" as String?)::plus)(Long.MAX_VALUE)) return "fail \"\"?::plus"
|
||||||
if (MAX_LONG != emptyStringNPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)"
|
// if (MAX_LONG != emptyStringNPlus(Long.MAX_VALUE)) return "fail emptyStringPlus(Long.MAX_VALUE)"
|
||||||
if (MAX_LONG != customToString(Long.MAX_VALUE, ("" as String?)::plus)) return "fail customToString(Long.MAX_VALUE, (\"\" as String?)::plus)"
|
// if (MAX_LONG != customToString(Long.MAX_VALUE, ("" as String?)::plus)) return "fail customToString(Long.MAX_VALUE, (\"\" as String?)::plus)"
|
||||||
|
|
||||||
if (PREFIX + MAX_LONG != "max = ${Long.MAX_VALUE}") return "fail template with prefix"
|
if (PREFIX + MAX_LONG != "max = ${Long.MAX_VALUE}") return "fail template with prefix"
|
||||||
if (PREFIX + MAX_LONG != PREFIX + Long.MAX_VALUE) return "fail \"$PREFIX\" +"
|
if (PREFIX + MAX_LONG != PREFIX + Long.MAX_VALUE) return "fail \"$PREFIX\" +"
|
||||||
@@ -37,17 +37,17 @@ fun box(): String {
|
|||||||
if (PREFIX + MAX_LONG != PREFIX.plus(Long.MAX_VALUE)) return "fail \"$PREFIX\".plus"
|
if (PREFIX + MAX_LONG != PREFIX.plus(Long.MAX_VALUE)) return "fail \"$PREFIX\".plus"
|
||||||
if (PREFIX + MAX_LONG != (PREFIX as String?).plus(Long.MAX_VALUE)) return "fail \"$PREFIX\"?.plus"
|
if (PREFIX + MAX_LONG != (PREFIX as String?).plus(Long.MAX_VALUE)) return "fail \"$PREFIX\"?.plus"
|
||||||
if (PREFIX + MAX_LONG != (String::plus)(PREFIX, Long.MAX_VALUE)) return "fail String::plus(\"$PREFIX\", ...)"
|
if (PREFIX + MAX_LONG != (String::plus)(PREFIX, Long.MAX_VALUE)) return "fail String::plus(\"$PREFIX\", ...)"
|
||||||
if (PREFIX + MAX_LONG != stringPlus(PREFIX, Long.MAX_VALUE)) return "fail stringPlus(\"$PREFIX\", Long.MAX_VALUE)"
|
// if (PREFIX + MAX_LONG != stringPlus(PREFIX, Long.MAX_VALUE)) return "fail stringPlus(\"$PREFIX\", Long.MAX_VALUE)"
|
||||||
if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String::plus)"
|
// if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String::plus)"
|
||||||
if (PREFIX + MAX_LONG != (String?::plus)(PREFIX, Long.MAX_VALUE)) return "fail String?::plus(\"$PREFIX\", ...)"
|
if (PREFIX + MAX_LONG != (String?::plus)(PREFIX, Long.MAX_VALUE)) return "fail String?::plus(\"$PREFIX\", ...)"
|
||||||
if (PREFIX + MAX_LONG != stringNPlus(PREFIX, Long.MAX_VALUE)) return "fail stringNPlus(\"$PREFIX\", Long.MAX_VALUE)"
|
// if (PREFIX + MAX_LONG != stringNPlus(PREFIX, Long.MAX_VALUE)) return "fail stringNPlus(\"$PREFIX\", Long.MAX_VALUE)"
|
||||||
if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String?::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String?::plus)"
|
// if (PREFIX + MAX_LONG != customToString(PREFIX, Long.MAX_VALUE, String?::plus)) return "fail customToString(\"$PREFIX\", Long.MAX_VALUE, String?::plus)"
|
||||||
if (PREFIX + MAX_LONG != (PREFIX::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"::plus"
|
if (PREFIX + MAX_LONG != (PREFIX::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"::plus"
|
||||||
if (PREFIX + MAX_LONG != prefixPlus(Long.MAX_VALUE)) return "fail prefixPlus(Long.MAX_VALUE)"
|
// if (PREFIX + MAX_LONG != prefixPlus(Long.MAX_VALUE)) return "fail prefixPlus(Long.MAX_VALUE)"
|
||||||
if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, PREFIX::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"::plus)"
|
// if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, PREFIX::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"::plus)"
|
||||||
if (PREFIX + MAX_LONG != ((PREFIX as String?)::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"?::plus"
|
if (PREFIX + MAX_LONG != ((PREFIX as String?)::plus)(Long.MAX_VALUE)) return "fail \"$PREFIX\"?::plus"
|
||||||
if (PREFIX + MAX_LONG != prefixNPlus(Long.MAX_VALUE)) return "fail prefixNPlus(Long.MAX_VALUE)"
|
// if (PREFIX + MAX_LONG != prefixNPlus(Long.MAX_VALUE)) return "fail prefixNPlus(Long.MAX_VALUE)"
|
||||||
if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, (PREFIX as String?)::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"?::plus)"
|
// if (PREFIX + MAX_LONG != customToString(Long.MAX_VALUE, (PREFIX as String?)::plus)) return "fail customToString(Long.MAX_VALUE, \"$PREFIX\"?::plus)"
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7414,6 +7414,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/native/library.kt");
|
runTest("js/js.translator/testData/box/native/library.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("long.kt")
|
||||||
|
public void testLong() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/native/long.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nativeClassAsReifiedTypeArgument.kt")
|
@TestMetadata("nativeClassAsReifiedTypeArgument.kt")
|
||||||
public void testNativeClassAsReifiedTypeArgument() throws Exception {
|
public void testNativeClassAsReifiedTypeArgument() throws Exception {
|
||||||
|
|||||||
+6
@@ -7792,6 +7792,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
|||||||
runTest("js/js.translator/testData/box/native/kt2209.kt");
|
runTest("js/js.translator/testData/box/native/kt2209.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("long.kt")
|
||||||
|
public void testLong() throws Exception {
|
||||||
|
runTest("js/js.translator/testData/box/native/long.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nativeClassAsReifiedTypeArgument.kt")
|
@TestMetadata("nativeClassAsReifiedTypeArgument.kt")
|
||||||
public void testNativeClassAsReifiedTypeArgument() throws Exception {
|
public void testNativeClassAsReifiedTypeArgument() throws Exception {
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ fun testKt14013() {
|
|||||||
if (testUtils.isLegacyBackend()) {
|
if (testUtils.isLegacyBackend()) {
|
||||||
assertEquals(",1;[...];,1;", pullLog(), "testKt14013")
|
assertEquals(",1;[...];,1;", pullLog(), "testKt14013")
|
||||||
} else {
|
} else {
|
||||||
assertEquals(",1;[...];[...];", pullLog(), "testKt14013")
|
assertEquals("[...];[...];[...];", pullLog(), "testKt14013")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ fun box(): String {
|
|||||||
if (testUtils.isLegacyBackend()) {
|
if (testUtils.isLegacyBackend()) {
|
||||||
assertEquals("1,2,3;1,2,3;[...];", pullLog(), "anyValueToString")
|
assertEquals("1,2,3;1,2,3;[...];", pullLog(), "anyValueToString")
|
||||||
} else {
|
} else {
|
||||||
assertEquals("[...];1,2,3;1,2,3;", pullLog(), "anyValueToString")
|
assertEquals("[...];[...];[...];", pullLog(), "anyValueToString")
|
||||||
}
|
}
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// EXPECTED_REACHABLE_NODES: 1273
|
||||||
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
|
// WASM_MUTE_REASON: UNSUPPORTED_JS_INTEROP
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
|
||||||
|
// Test that APIs expecting Number behave correctly with Long values.
|
||||||
|
|
||||||
|
import kotlin.js.Date
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assertEquals("1970-01-01T00:00:00.000Z", Date(0L).toISOString())
|
||||||
|
assertEquals("10/4/1995, 12:00:00 AM", Date(1995, 9, 4, 0, 0, 0, 0L).toLocaleString("en-US"))
|
||||||
|
assertEquals(812764800000.0, Date.UTC(1995, 9, 4, 0, 0, 0, 0L))
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+33
-33
@@ -39,39 +39,39 @@ fun box(): String {
|
|||||||
if (" ${null as Number?}" != " null") return "FAIL 10"
|
if (" ${null as Number?}" != " null") return "FAIL 10"
|
||||||
if (" ${x.toLong() as Any?}" != " $x") return "FAIL 11"
|
if (" ${x.toLong() as Any?}" != " $x") return "FAIL 11"
|
||||||
if (" ${null as Any?}" != " null") return "FAIL 12"
|
if (" ${null as Any?}" != " null") return "FAIL 12"
|
||||||
if (!testUtils.isLegacyBackend()) {
|
// if (!testUtils.isLegacyBackend()) {
|
||||||
if (longToString(x.toLong()) != " $x") return "FAIL 13"
|
// if (longToString(x.toLong()) != " $x") return "FAIL 13"
|
||||||
if (nullableLongToString1(x.toLong()) != " $x") return "FAIL 14"
|
// if (nullableLongToString1(x.toLong()) != " $x") return "FAIL 14"
|
||||||
if (nullableLongToString1(null) != " null") return "FAIL 15"
|
// if (nullableLongToString1(null) != " null") return "FAIL 15"
|
||||||
if (nullableLongToString2(x.toLong()) != " $x") return "FAIL 16"
|
// if (nullableLongToString2(x.toLong()) != " $x") return "FAIL 16"
|
||||||
if (nullableLongToString2(null) != " null") return "FAIL 17"
|
// if (nullableLongToString2(null) != " null") return "FAIL 17"
|
||||||
if (nullableLongToString3(x.toLong()) != " $x") return "FAIL 18"
|
// if (nullableLongToString3(x.toLong()) != " $x") return "FAIL 18"
|
||||||
if (nullableLongToString3(null) != " null") return "FAIL 19"
|
// if (nullableLongToString3(null) != " null") return "FAIL 19"
|
||||||
if (numberToString(x.toLong()) != " $x") return "FAIL 20"
|
// if (numberToString(x.toLong()) != " $x") return "FAIL 20"
|
||||||
if (nullableNumberToString1(x.toLong()) != " $x") return "FAIL 21"
|
// if (nullableNumberToString1(x.toLong()) != " $x") return "FAIL 21"
|
||||||
if (nullableNumberToString1(null) != " null") return "FAIL 22"
|
// if (nullableNumberToString1(null) != " null") return "FAIL 22"
|
||||||
if (nullableNumberToString2(x.toLong()) != " $x") return "FAIL 23"
|
// if (nullableNumberToString2(x.toLong()) != " $x") return "FAIL 23"
|
||||||
if (nullableNumberToString2(null) != " null") return "FAIL 24"
|
// if (nullableNumberToString2(null) != " null") return "FAIL 24"
|
||||||
if (nullableNumberToString3(x.toLong()) != " $x") return "FAIL 25"
|
// if (nullableNumberToString3(x.toLong()) != " $x") return "FAIL 25"
|
||||||
if (nullableNumberToString3(null) != " null") return "FAIL 26"
|
// if (nullableNumberToString3(null) != " null") return "FAIL 26"
|
||||||
if (comparableToString(x.toLong()) != " $x") return "FAIL 27"
|
// if (comparableToString(x.toLong()) != " $x") return "FAIL 27"
|
||||||
if (nullableComparableToString1(x.toLong()) != " $x") return "FAIL 28"
|
// if (nullableComparableToString1(x.toLong()) != " $x") return "FAIL 28"
|
||||||
if (nullableComparableToString1(null) != " null") return "FAIL 29"
|
// if (nullableComparableToString1(null) != " null") return "FAIL 29"
|
||||||
if (nullableComparableToString2(x.toLong()) != " $x") return "FAIL 30"
|
// if (nullableComparableToString2(x.toLong()) != " $x") return "FAIL 30"
|
||||||
if (nullableComparableToString2(null) != " null") return "FAIL 31"
|
// if (nullableComparableToString2(null) != " null") return "FAIL 31"
|
||||||
if (nullableComparableToString3(x.toLong()) != " $x") return "FAIL 32"
|
// if (nullableComparableToString3(x.toLong()) != " $x") return "FAIL 32"
|
||||||
if (nullableComparableToString3(null) != " null") return "FAIL 33"
|
// if (nullableComparableToString3(null) != " null") return "FAIL 33"
|
||||||
if (anyToString(x.toLong()) != " $x") return "FAIL 34"
|
// if (anyToString(x.toLong()) != " $x") return "FAIL 34"
|
||||||
if (nullableAnyToString1(x.toLong()) != " $x") return "FAIL 35"
|
// if (nullableAnyToString1(x.toLong()) != " $x") return "FAIL 35"
|
||||||
if (nullableAnyToString1(null) != " null") return "FAIL 36"
|
// if (nullableAnyToString1(null) != " null") return "FAIL 36"
|
||||||
if (nullableAnyToString2(x.toLong()) != " $x") return "FAIL 37"
|
// if (nullableAnyToString2(x.toLong()) != " $x") return "FAIL 37"
|
||||||
if (nullableAnyToString2(null) != " null") return "FAIL 38"
|
// if (nullableAnyToString2(null) != " null") return "FAIL 38"
|
||||||
if (nullableAnyToString3(x.toLong()) != " $x") return "FAIL 39"
|
// if (nullableAnyToString3(x.toLong()) != " $x") return "FAIL 39"
|
||||||
if (nullableAnyToString3(null) != " null") return "FAIL 40"
|
// if (nullableAnyToString3(null) != " null") return "FAIL 40"
|
||||||
if (arbitraryToString(x.toLong()) != " $x") return "FAIL 41"
|
// if (arbitraryToString(x.toLong()) != " $x") return "FAIL 41"
|
||||||
if (nullableArbitraryToString(x.toLong()) != " $x") return "FAIL 42"
|
// if (nullableArbitraryToString(x.toLong()) != " $x") return "FAIL 42"
|
||||||
if (nullableArbitraryToString(null) != " null") return "FAIL 43"
|
// if (nullableArbitraryToString(null) != " null") return "FAIL 43"
|
||||||
}
|
// }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -279,6 +279,15 @@ public class Long internal constructor(
|
|||||||
public override fun toFloat(): Float = toDouble().toFloat()
|
public override fun toFloat(): Float = toDouble().toFloat()
|
||||||
public override fun toDouble(): Double = toNumber()
|
public override fun toDouble(): Double = toNumber()
|
||||||
|
|
||||||
|
// This method is used by JavaScript to convert objects of type Long to primitives.
|
||||||
|
// This is essential for the JavaScript interop.
|
||||||
|
// JavaScript functions that expect `number` are imported in Kotlin as expecting `kotlin.Number`
|
||||||
|
// (in our standard library, and also in user projects if they use Dukat for generating external declarations).
|
||||||
|
// Because `kotlin.Number` is a supertype of `Long` too, there has to be a way for JS to know how to handle Longs.
|
||||||
|
// See KT-50202
|
||||||
|
@JsName("valueOf")
|
||||||
|
internal fun valueOf() = toDouble()
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = other is Long && equalsLong(other)
|
override fun equals(other: Any?): Boolean = other is Long && equalsLong(other)
|
||||||
|
|
||||||
override fun hashCode(): Int = hashCode(this)
|
override fun hashCode(): Int = hashCode(this)
|
||||||
|
|||||||
Reference in New Issue
Block a user