diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt index b34674628414e..8560e0b1cfd60 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt @@ -3767,46 +3767,6 @@ OLD: KE1 // We need to handle all the builtin operators defines in BuiltInOperatorNames in // compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt // as they can't be extracted as external dependencies. - isBuiltinCallInternal(c, "less") -> { - if (c.origin != IrStatementOrigin.LT) { - logger.warnElement("Unexpected origin for LT: ${c.origin}", c) - } - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_ltexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, c, callable, enclosingStmt) - } - isBuiltinCallInternal(c, "lessOrEqual") -> { - if (c.origin != IrStatementOrigin.LTEQ) { - logger.warnElement("Unexpected origin for LTEQ: ${c.origin}", c) - } - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_leexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, c, callable, enclosingStmt) - } - isBuiltinCallInternal(c, "greater") -> { - if (c.origin != IrStatementOrigin.GT) { - logger.warnElement("Unexpected origin for GT: ${c.origin}", c) - } - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_gtexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, c, callable, enclosingStmt) - } - isBuiltinCallInternal(c, "greaterOrEqual") -> { - if (c.origin != IrStatementOrigin.GTEQ) { - logger.warnElement("Unexpected origin for GTEQ: ${c.origin}", c) - } - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_geexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, c, callable, enclosingStmt) - } isBuiltinCallInternal(c, "EQEQ") -> { if (c.origin != IrStatementOrigin.EQEQ) { logger.warnElement("Unexpected origin for EQEQ: ${c.origin}", c) diff --git a/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt b/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt index acb29da515bff..6d9c768fd9da8 100644 --- a/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt +++ b/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt @@ -318,8 +318,21 @@ private fun KotlinFileExtractor.extractBinaryExpression( extractBinaryExpression(expression, callable, parent, tw::writeExprs_eqexpr) } else if (op == KtTokens.EXCLEQEQEQ && target == null) { extractBinaryExpression(expression, callable, parent, tw::writeExprs_neexpr) + } else if (op in listOf(KtTokens.LT, KtTokens.GT, KtTokens.LTEQ, KtTokens.GTEQ)) { + if (target.isNumericWithName("compareTo")) { + when (op) { + KtTokens.LT -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_ltexpr) + KtTokens.GT -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_gtexpr) + KtTokens.LTEQ -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_leexpr) + KtTokens.GTEQ -> extractBinaryExpression(expression, callable, parent, tw::writeExprs_gtexpr) + else -> TODO("error") + } + } else { + TODO("Extract lowered equivalent call, such as `a.compareTo(b) < 0`") + } + } else { - // todo: other operators, such as .., ..<, in, !in, +=, -=, *=, /=, %=, <, >, <=, >=, ==, !=, + // todo: other operators, such as .., ..<, in, !in, =, +=, -=, *=, /=, %=, ==, !=, TODO("Extract as method call") } }