[JS IR BE] Don't mangle Any::equals method
This commit is contained in:
+1
-6
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.ir.backend.js.lower.calls
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||||
|
import org.jetbrains.kotlin.ir.backend.js.utils.isEqualsInheritedFromAny
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrCall
|
import org.jetbrains.kotlin.ir.expressions.IrCall
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
@@ -172,10 +173,4 @@ class EqualityAndComparisonCallsTransformer(context: JsIrBackendContext) : Calls
|
|||||||
private fun IrFunction.isMethodOfPotentiallyPrimitiveJSType() =
|
private fun IrFunction.isMethodOfPotentiallyPrimitiveJSType() =
|
||||||
isMethodOfPrimitiveJSType() || isFakeOverriddenFromAny()
|
isMethodOfPrimitiveJSType() || isFakeOverriddenFromAny()
|
||||||
|
|
||||||
private fun IrFunction.isEqualsInheritedFromAny() =
|
|
||||||
name == Name.identifier("equals") &&
|
|
||||||
dispatchReceiverParameter != null &&
|
|
||||||
valueParameters.size == 1 &&
|
|
||||||
valueParameters[0].type.isNullableAny()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -143,6 +143,11 @@ class SimpleNameGenerator : NameGenerator {
|
|||||||
}
|
}
|
||||||
is IrSimpleFunction -> {
|
is IrSimpleFunction -> {
|
||||||
|
|
||||||
|
// Handle names for special functions
|
||||||
|
if (declaration.isEqualsInheritedFromAny()) {
|
||||||
|
return context.staticContext.rootScope.declareName("equals")
|
||||||
|
}
|
||||||
|
|
||||||
if (declaration.isStaticMethodOfClass) {
|
if (declaration.isStaticMethodOfClass) {
|
||||||
nameBuilder.append(getNameForDeclaration(declaration.parent as IrClass, context))
|
nameBuilder.append(getNameForDeclaration(declaration.parent as IrClass, context))
|
||||||
nameBuilder.append('.')
|
nameBuilder.append('.')
|
||||||
|
|||||||
@@ -6,5 +6,14 @@
|
|||||||
package org.jetbrains.kotlin.ir.backend.js.utils
|
package org.jetbrains.kotlin.ir.backend.js.utils
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
|
import org.jetbrains.kotlin.ir.types.isNullableAny
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
fun TODO(element: IrElement): Nothing = TODO(element::class.java.simpleName + " is not supported yet here")
|
fun TODO(element: IrElement): Nothing = TODO(element::class.java.simpleName + " is not supported yet here")
|
||||||
|
|
||||||
|
fun IrFunction.isEqualsInheritedFromAny() =
|
||||||
|
name == Name.identifier("equals") &&
|
||||||
|
dispatchReceiverParameter != null &&
|
||||||
|
valueParameters.size == 1 &&
|
||||||
|
valueParameters[0].type.isNullableAny()
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND: JS_IR
|
|
||||||
// EXPECTED_REACHABLE_NODES: 1290
|
// EXPECTED_REACHABLE_NODES: 1290
|
||||||
data class A(val number: Int)
|
data class A(val number: Int)
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ fun equals(obj1: dynamic, obj2: dynamic): Boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return js("""
|
return js("""
|
||||||
if (typeof obj1 === "object" && typeof obj1.equals_kotlin_Any_ === "function") {
|
if (typeof obj1 === "object" && typeof obj1.equals === "function") {
|
||||||
return obj1.equals_kotlin_Any_(obj2);
|
return obj1.equals(obj2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj1 !== obj1) {
|
if (obj1 !== obj1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user