diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt index b9ac80027b4..53b90b74c4c 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt @@ -2992,18 +2992,6 @@ OLD: KE1 tw.writeExprsKotlinType(id, type.kotlinResult.id) binOp(id, dr, callable, enclosingStmt) } - c.origin == IrStatementOrigin.EXCLEQEQ && - isFunction(target, "kotlin", "Boolean", "not") && - c.valueArgumentsCount == 0 && - dr != null && - dr is IrCall && - isBuiltinCallInternal(dr, "EQEQEQ") -> { - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_neexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, dr, callable, enclosingStmt) - } c.origin == IrStatementOrigin.EXCLEQ && isFunction(target, "kotlin", "Boolean", "not") && c.valueArgumentsCount == 0 && @@ -3113,16 +3101,6 @@ OLD: KE1 tw.writeExprsKotlinType(id, type.kotlinResult.id) binOp(id, c, callable, enclosingStmt) } - isBuiltinCallInternal(c, "EQEQEQ") -> { - if (c.origin != IrStatementOrigin.EQEQEQ) { - logger.warnElement("Unexpected origin for EQEQEQ: ${c.origin}", c) - } - val id = tw.getFreshIdLabel() - val type = useType(c.type) - tw.writeExprs_eqexpr(id, type.javaResult.id, parent, idx) - tw.writeExprsKotlinType(id, type.kotlinResult.id) - binOp(id, c, callable, enclosingStmt) - } isBuiltinCallInternal(c, "ieee754equals") -> { if (c.origin != IrStatementOrigin.EQEQ) { logger.warnElement("Unexpected origin for ieee754equals: ${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 14a30938b80..312d34fabcf 100644 --- a/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt +++ b/java/kotlin-extractor2/src/main/kotlin/entities/Expression.kt @@ -256,13 +256,14 @@ private fun KaFunctionSymbol.hasName( ) } -private fun KaFunctionSymbol.isNumericWithName(functionName: String): Boolean { - return this.hasName("kotlin", "Int", functionName) || - this.hasName("kotlin", "Byte", functionName) || - this.hasName("kotlin", "Short", functionName) || - this.hasName("kotlin", "Long", functionName) || - this.hasName("kotlin", "Float", functionName) || - this.hasName("kotlin", "Double", functionName) +private fun KaFunctionSymbol?.isNumericWithName(functionName: String): Boolean { + return this != null && + (this.hasName("kotlin", "Int", functionName) || + this.hasName("kotlin", "Byte", functionName) || + this.hasName("kotlin", "Short", functionName) || + this.hasName("kotlin", "Long", functionName) || + this.hasName("kotlin", "Float", functionName) || + this.hasName("kotlin", "Double", functionName)) } context(KaSession) @@ -297,10 +298,6 @@ private fun KotlinFileExtractor.extractBinaryExpression( val op = expression.operationToken val target = expression.resolveCallTarget()?.symbol - if (target == null) { - TODO() - } - if (op == KtTokens.PLUS && target.isBinaryPlus()) { extractBinaryExpression(expression, callable, parent, tw::writeExprs_addexpr) } else if (op == KtTokens.MINUS && target.isNumericWithName("minus")) { @@ -323,19 +320,24 @@ private fun KotlinFileExtractor.extractBinaryExpression( extractBinaryExpression(expression, callable, parent, tw::writeExprs_rshiftexpr) } else if (op == KtTokens.IDENTIFIER && target.isNumericWithName("ushr")) { extractBinaryExpression(expression, callable, parent, tw::writeExprs_urshiftexpr) + } else if (op == KtTokens.EQEQEQ && target == null) { + extractBinaryExpression(expression, callable, parent, tw::writeExprs_eqexpr) + } else if (op == KtTokens.EXCLEQEQEQ && target == null) { + extractBinaryExpression(expression, callable, parent, tw::writeExprs_neexpr) } else { TODO("Extract as method call") } } -private fun KaFunctionSymbol.isBinaryPlus(): Boolean { - return this.isNumericWithName("plus") || - this.hasName("kotlin", "String", "plus") || - this.hasMatchingNames( - CallableId(FqName("kotlin"), null, Name.identifier("plus")), - ClassId(FqName("kotlin"), Name.identifier("String")), - nullability = KaTypeNullability.NULLABLE, - ) +private fun KaFunctionSymbol?.isBinaryPlus(): Boolean { + return this != null && ( + this.isNumericWithName("plus") || + this.hasName("kotlin", "String", "plus") || + this.hasMatchingNames( + CallableId(FqName("kotlin"), null, Name.identifier("plus")), + ClassId(FqName("kotlin"), Name.identifier("String")), + nullability = KaTypeNullability.NULLABLE, + )) } context(KaSession)