@@ -1544,22 +1544,22 @@ open class KotlinFileExtractor(
15441544 binopDisp(id)
15451545 }
15461546 // != gets desugared into not and ==. Here we resugar it.
1547+ // TODO: This is wrong. Kotlin `a == b` is `a?.equals(b) ?: (b === null)`
15471548 c.origin == EXCLEQ && isFunction(" kotlin" , " Boolean" , " not" ) && c.valueArgumentsCount == 0 && dr != null && dr is IrCall && isBuiltinCall(dr, " EQEQ" ) -> {
15481549 val id = tw.getFreshIdLabel<DbNeexpr >()
15491550 val type = useType(c.type)
15501551 tw.writeExprs_neexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
15511552 binop(id, dr, callable)
15521553 }
1553- // compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
1554- isBuiltinCall(c, " EQEQ" ) -> {
1555- if (c.origin != EQEQ ) {
1556- logger.warnElement(Severity .ErrorSevere , " Unexpected origin for EQEQ: ${c.origin} " , c)
1557- }
1558- val id = tw.getFreshIdLabel<DbEqexpr >()
1554+ c.origin == EXCLEQEQ && isFunction(" kotlin" , " Boolean" , " not" ) && c.valueArgumentsCount == 0 && dr != null && dr is IrCall && isBuiltinCall(dr, " EQEQEQ" ) -> {
1555+ val id = tw.getFreshIdLabel<DbNeexpr >()
15591556 val type = useType(c.type)
1560- tw.writeExprs_eqexpr (id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1561- binop(id, c , callable)
1557+ tw.writeExprs_neexpr (id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1558+ binop(id, dr , callable)
15621559 }
1560+ // We need to handle all the builtin operators defines in BuiltInOperatorNames in
1561+ // compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt
1562+ // as they can't be extracted as external dependencies.
15631563 isBuiltinCall(c, " less" ) -> {
15641564 if (c.origin != LT ) {
15651565 logger.warnElement(Severity .ErrorSevere , " Unexpected origin for LT: ${c.origin} " , c)
@@ -1596,6 +1596,25 @@ open class KotlinFileExtractor(
15961596 tw.writeExprs_geexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
15971597 binop(id, c, callable)
15981598 }
1599+ isBuiltinCall(c, " EQEQ" ) -> {
1600+ if (c.origin != EQEQ ) {
1601+ logger.warnElement(Severity .ErrorSevere , " Unexpected origin for EQEQ: ${c.origin} " , c)
1602+ }
1603+ // TODO: This is wrong. Kotlin `a == b` is `a?.equals(b) ?: (b === null)`
1604+ val id = tw.getFreshIdLabel<DbEqexpr >()
1605+ val type = useType(c.type)
1606+ tw.writeExprs_eqexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1607+ binop(id, c, callable)
1608+ }
1609+ isBuiltinCall(c, " EQEQEQ" ) -> {
1610+ if (c.origin != EQEQEQ ) {
1611+ logger.warnElement(Severity .ErrorSevere , " Unexpected origin for EQEQEQ: ${c.origin} " , c)
1612+ }
1613+ val id = tw.getFreshIdLabel<DbEqexpr >()
1614+ val type = useType(c.type)
1615+ tw.writeExprs_eqexpr(id, type.javaResult.id, type.kotlinResult.id, parent, idx)
1616+ binop(id, c, callable)
1617+ }
15991618 else -> {
16001619 val id = tw.getFreshIdLabel<DbMethodaccess >()
16011620 val type = useType(c.type)
0 commit comments