Skip to content

Commit 5801279

Browse files
committed
[JS IR] De-optimize equality operator as workaround for KT-57509
(cherry picked from commit 32d1fba)
1 parent 79d3dda commit 5801279

File tree

6 files changed

+44
-2
lines changed

6 files changed

+44
-2
lines changed

compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/calls/EqualityAndComparisonCallsTransformer.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@ class EqualityAndComparisonCallsTransformer(context: JsIrBackendContext) : Calls
9999
val equalsMethod = lhs.type.findEqualsMethod()
100100

101101
return when {
102-
lhs.type is IrDynamicType ->
103-
irCall(call, intrinsics.jsEqeq)
102+
// Temporarily de-optimize dynamic equality due to KT-57509
103+
// lhs.type is IrDynamicType ->
104+
// irCall(call, intrinsics.jsEqeq)
104105

105106
// Special optimization for "<expression> == null"
106107
lhs.isNullConst() || rhs.isNullConst() ->

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsBoxTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsES6TestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// WITH_STDLIB
2+
3+
fun demo(x: dynamic, a: Array<out dynamic>): Boolean? {
4+
return a.any { y: Any ->
5+
val newX: Any = x.unsafeCast<Any>()
6+
y == newX
7+
}
8+
}
9+
10+
data class X(val x: Int)
11+
12+
fun box(): String {
13+
14+
if (demo(X(1), arrayOf(X(1))) != true) return "fail"
15+
16+
return "OK"
17+
}

0 commit comments

Comments
 (0)