diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index ce0f5cabdf4..67712a45e54 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -12,7 +12,9 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.* +import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition +import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression +import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression import org.jetbrains.kotlin.fir.references.FirReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.references.FirSuperReference @@ -24,6 +26,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.IntegerLiteralTypeApproxima import org.jetbrains.kotlin.fir.scopes.impl.FirClassSubstitutionScope import org.jetbrains.kotlin.fir.scopes.impl.FirIntegerOperator import org.jetbrains.kotlin.fir.symbols.AccessorSymbol +import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor @@ -44,12 +47,9 @@ import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.lexer.KtTokens -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi2ir.PsiSourceManager -import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker import java.util.* class Fir2IrVisitor( @@ -864,7 +864,7 @@ class Fir2IrVisitor( } } - override fun visitFunctionCall(functionCall: FirFunctionCall, data: Any?): IrElement { + override fun visitFunctionCall(functionCall: FirFunctionCall, data: Any?): IrExpression { val convertibleCall = if (functionCall.toResolvedCallableSymbol()?.fir is FirIntegerOperator) { functionCall.copy().transformSingle(integerApproximator, null) } else { @@ -1312,50 +1312,72 @@ class Fir2IrVisitor( } } - private fun generateComparisonCall( - startOffset: Int, endOffset: Int, operation: FirOperation, first: FirExpression, second: FirExpression - ): IrExpression { - val firstType = first.typeRef as? FirResolvedTypeRef - val secondType = second.typeRef as? FirResolvedTypeRef - if (firstType == null || secondType == null) { - return IrErrorCallExpressionImpl(startOffset, endOffset, booleanType, "Comparison of arguments with unresolved types") + override fun visitComparisonExpression(comparisonExpression: FirComparisonExpression, data: Any?): IrElement { + return comparisonExpression.convertWithOffsets { startOffset, endOffset -> + generateComparisonCall(startOffset, endOffset, comparisonExpression) } - if (!AbstractStrictEqualityTypeChecker.strictEqualTypes(typeContext, firstType.type, secondType.type)) { - return IrErrorCallExpressionImpl( - startOffset, endOffset, booleanType, - "Comparison of arguments with different types: ${firstType.type.render()}, ${secondType.type.render()}" + } + + private fun generateComparisonCall( + startOffset: Int, endOffset: Int, + comparisonExpression: FirComparisonExpression + ): IrExpression { + val operation = comparisonExpression.operation + + fun fallbackToRealCall(): IrExpression { + val (symbol, origin) = getSymbolAndOriginForComparison(operation, irBuiltIns.intType.classifierOrFail) + return primitiveOp2( + startOffset, endOffset, + symbol!!, + booleanType, + origin, + visitFunctionCall(comparisonExpression.compareToCall, null), + IrConstImpl.int(startOffset, endOffset, irBuiltIns.intType, 0) ) } - // TODO: it's temporary hack which should be refactored - val simpleType = when (val classId = (firstType.type as? ConeClassLikeType)?.lookupTag?.classId) { - ClassId(FqName("kotlin"), FqName("Long"), false) -> irBuiltIns.longType - ClassId(FqName("kotlin"), FqName("Int"), false) -> irBuiltIns.intType - ClassId(FqName("kotlin"), FqName("Float"), false) -> irBuiltIns.floatType - ClassId(FqName("kotlin"), FqName("Double"), false) -> irBuiltIns.doubleType - ClassId(FqName("kotlin"), FqName("Char"), false) -> irBuiltIns.charType - else -> { - return IrErrorCallExpressionImpl( - startOffset, endOffset, booleanType, "Comparison of arguments with unsupported type: $classId" - ) - } + + val comparisonInfo = comparisonExpression.inferPrimitiveNumericComparisonInfo() ?: return fallbackToRealCall() + val comparisonType = comparisonInfo.comparisonType + + // Currently inferPrimitiveNumericComparisonInfo returns null for different primitive values + // TODO: Support different primitive types as well and fix inferPrimitiveNumericComparisonInfo + require(comparisonInfo.leftPrimitiveType == comparisonInfo.rightPrimitiveType && comparisonInfo.leftType == comparisonInfo.rightType) { + "Contract for inferPrimitiveNumericComparisonInfo is violated" } - val classifier = simpleType.classifierOrFail - val (symbol, origin) = when (operation) { + + val simpleType = when ((comparisonType.type as? ConeClassLikeType)?.lookupTag?.classId) { + StandardClassIds.Long -> irBuiltIns.longType + StandardClassIds.Int -> irBuiltIns.intType + StandardClassIds.Float -> irBuiltIns.floatType + StandardClassIds.Double -> irBuiltIns.doubleType + StandardClassIds.Char -> irBuiltIns.charType + else -> return fallbackToRealCall() + } + + val (symbol, origin) = getSymbolAndOriginForComparison(operation, simpleType.classifierOrFail) + + return primitiveOp2( + startOffset, endOffset, symbol!!, booleanType, origin, + comparisonExpression.left.toIrExpression(), comparisonExpression.right.toIrExpression() + ) + } + + private fun getSymbolAndOriginForComparison( + operation: FirOperation, + classifier: IrClassifierSymbol + ): Pair { + return when (operation) { FirOperation.LT -> irBuiltIns.lessFunByOperandType[classifier] to IrStatementOrigin.LT FirOperation.GT -> irBuiltIns.greaterFunByOperandType[classifier] to IrStatementOrigin.GT FirOperation.LT_EQ -> irBuiltIns.lessOrEqualFunByOperandType[classifier] to IrStatementOrigin.LTEQ FirOperation.GT_EQ -> irBuiltIns.greaterOrEqualFunByOperandType[classifier] to IrStatementOrigin.GTEQ - else -> throw AssertionError("Unexpected comparison operation: $operation") + else -> error("Unexpected comparison operation: $operation") } - return primitiveOp2(startOffset, endOffset, symbol!!, booleanType, origin, first.toIrExpression(), second.toIrExpression()) } private fun generateOperatorCall( startOffset: Int, endOffset: Int, operation: FirOperation, arguments: List ): IrExpression { - if (operation in FirOperation.COMPARISONS) { - return generateComparisonCall(startOffset, endOffset, operation, arguments[0], arguments[1]) - } val (type, symbol, origin) = when (operation) { FirOperation.EQ -> Triple(booleanType, irBuiltIns.eqeqSymbol, IrStatementOrigin.EQEQ) FirOperation.NOT_EQ -> Triple(booleanType, irBuiltIns.eqeqSymbol, IrStatementOrigin.EXCLEQ) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/PrimitiveComparison.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/PrimitiveComparison.kt new file mode 100644 index 00000000000..173acec1377 --- /dev/null +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/PrimitiveComparison.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.backend + +import org.jetbrains.kotlin.fir.* +import org.jetbrains.kotlin.fir.expressions.FirComparisonExpression +import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.resolve.firSymbolProvider +import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult + +class PrimitiveConeNumericComparisonInfo( + val comparisonType: ConeKotlinType, + val leftPrimitiveType: ConeClassLikeType, + val rightPrimitiveType: ConeClassLikeType, + val leftType: ConeKotlinType, + val rightType: ConeKotlinType +) + +val FirComparisonExpression.left: FirExpression + get() = compareToCall.explicitReceiver ?: error("There should be an explicit receiver for ${compareToCall.render()}") + +val FirComparisonExpression.right: FirExpression + get() = compareToCall.arguments.getOrNull(0) ?: error("There should be a first arg for ${compareToCall.render()}") + +fun FirComparisonExpression.inferPrimitiveNumericComparisonInfo(): PrimitiveConeNumericComparisonInfo? { + val leftType = left.typeRef.coneTypeSafe() ?: return null + val rightType = right.typeRef.coneTypeSafe() ?: return null + val leftPrimitiveOrNullableType = leftType.getPrimitiveTypeOrSupertype() ?: return null + val rightPrimitiveOrNullableType = rightType.getPrimitiveTypeOrSupertype() ?: return null + val leftPrimitiveType = leftPrimitiveOrNullableType.withNullability(ConeNullability.NOT_NULL) + val rightPrimitiveType = rightPrimitiveOrNullableType.withNullability(ConeNullability.NOT_NULL) + + // TODO: Support different types with coercion + if (leftPrimitiveType != rightPrimitiveType) return null + val leastCommonType = rightPrimitiveType + + return PrimitiveConeNumericComparisonInfo( + leastCommonType, + leftPrimitiveType, rightPrimitiveType, + leftPrimitiveOrNullableType, rightPrimitiveOrNullableType + ) +} + +private fun ConeKotlinType.getPrimitiveTypeOrSupertype(): ConeClassLikeType? = + when { + this is ConeTypeParameterType -> + this.lookupTag.typeParameterSymbol.fir.bounds.firstNotNullResult { + it.coneTypeSafe()?.getPrimitiveTypeOrSupertype() + } + this is ConeClassLikeType && isPrimitiveNumberType() -> + this + else -> + null + } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Primitives.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Primitives.kt new file mode 100644 index 00000000000..fe25ce4033c --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/Primitives.kt @@ -0,0 +1,40 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +import org.jetbrains.kotlin.fir.symbols.StandardClassIds +import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.types.ConeClassLikeType +import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl +import org.jetbrains.kotlin.name.ClassId + +object PrimitiveTypes { + val Boolean = StandardClassIds.Boolean.createType() + val Char = StandardClassIds.Char.createType() + val Byte = StandardClassIds.Byte.createType() + val Short = StandardClassIds.Short.createType() + val Int = StandardClassIds.Int.createType() + val Long = StandardClassIds.Long.createType() + val Float = StandardClassIds.Float.createType() + val Double = StandardClassIds.Double.createType() +} + +private fun ClassId.createType(): ConeClassLikeType = + ConeClassLikeTypeImpl(ConeClassLikeLookupTagImpl(this), emptyArray(), isNullable = false) + +fun ConeClassLikeType.isDouble() = lookupTag.classId == StandardClassIds.Double +fun ConeClassLikeType.isFloat() = lookupTag.classId == StandardClassIds.Float +fun ConeClassLikeType.isLong() = lookupTag.classId == StandardClassIds.Long +fun ConeClassLikeType.isInt() = lookupTag.classId == StandardClassIds.Int +fun ConeClassLikeType.isShort() = lookupTag.classId == StandardClassIds.Short +fun ConeClassLikeType.isByte() = lookupTag.classId == StandardClassIds.Byte + +private val PRIMITIVE_NUMBER_CLASS_IDS = setOf( + StandardClassIds.Double, StandardClassIds.Float, StandardClassIds.Long, StandardClassIds.Int, + StandardClassIds.Short, StandardClassIds.Byte +) + +fun ConeClassLikeType.isPrimitiveNumberType() = lookupTag.classId in PRIMITIVE_NUMBER_CLASS_IDS diff --git a/compiler/testData/codegen/box/binaryOp/kt11163.kt b/compiler/testData/codegen/box/binaryOp/kt11163.kt index a2a457d017a..39ec1db35d5 100644 --- a/compiler/testData/codegen/box/binaryOp/kt11163.kt +++ b/compiler/testData/codegen/box/binaryOp/kt11163.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR operator fun Int.compareTo(c: Char) = 0 fun foo(x: Int, y: Char): String { @@ -10,4 +9,4 @@ fun foo(x: Int, y: Char): String { fun box(): String { return foo(42, 'O') -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/binaryOp/kt11163_properIeee754comparisons.kt b/compiler/testData/codegen/box/binaryOp/kt11163_properIeee754comparisons.kt index 8f11e9cf625..13829eb2e67 100644 --- a/compiler/testData/codegen/box/binaryOp/kt11163_properIeee754comparisons.kt +++ b/compiler/testData/codegen/box/binaryOp/kt11163_properIeee754comparisons.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ProperIeee754Comparisons -// IGNORE_BACKEND_FIR: JVM_IR operator fun Int.compareTo(c: Char) = 0 fun foo(x: Int, y: Char): String { @@ -11,4 +10,4 @@ fun foo(x: Int, y: Char): String { fun box(): String { return foo(42, 'O') -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/boxingOptimization/boxedIntegersCmp.kt b/compiler/testData/codegen/box/boxingOptimization/boxedIntegersCmp.kt index a8e0ed3d714..69fc1801c3f 100644 --- a/compiler/testData/codegen/box/boxingOptimization/boxedIntegersCmp.kt +++ b/compiler/testData/codegen/box/boxingOptimization/boxedIntegersCmp.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR inline fun ltx(a: Comparable, b: Any) = a < b inline fun lex(a: Comparable, b: Any) = a <= b inline fun gex(a: Comparable, b: Any) = a >= b @@ -44,4 +43,4 @@ fun box(): String { else -> "OK" } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/boxingOptimization/boxedRealsCmp.kt b/compiler/testData/codegen/box/boxingOptimization/boxedRealsCmp.kt index b22e6f46d9b..4151703f166 100644 --- a/compiler/testData/codegen/box/boxingOptimization/boxedRealsCmp.kt +++ b/compiler/testData/codegen/box/boxingOptimization/boxedRealsCmp.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - inline fun ltx(a: Comparable, b: Any) = a < b inline fun lex(a: Comparable, b: Any) = a <= b inline fun gex(a: Comparable, b: Any) = a >= b @@ -79,4 +77,4 @@ fun box(): String { else -> "OK" } -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/classes/kt3114.kt b/compiler/testData/codegen/box/classes/kt3114.kt index 45731015045..f28569e1d97 100644 --- a/compiler/testData/codegen/box/classes/kt3114.kt +++ b/compiler/testData/codegen/box/classes/kt3114.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class KeySpan(val left: String) { public fun matches(value : String) : Boolean { @@ -11,4 +10,4 @@ class KeySpan(val left: String) { fun box() : String { KeySpan("1").matches("3") return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/functions/recursiveCompareTo.kt b/compiler/testData/codegen/box/functions/recursiveCompareTo.kt index b96d958d0ea..564f23a6a2f 100644 --- a/compiler/testData/codegen/box/functions/recursiveCompareTo.kt +++ b/compiler/testData/codegen/box/functions/recursiveCompareTo.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class C operator fun C.compareTo(o: C) : Int { @@ -9,4 +8,4 @@ operator fun C.compareTo(o: C) : Int { return -1 } -fun box() : String = if (C() > C()) "OK" else "FAIL" \ No newline at end of file +fun box() : String = if (C() > C()) "OK" else "FAIL" diff --git a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes.kt b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes.kt index a700508d7a5..43d35ecd86b 100644 --- a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes.kt +++ b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes.kt @@ -1,5 +1,4 @@ // !LANGUAGE: -ProperIeee754Comparisons -// IGNORE_BACKEND_FIR: JVM_IR // IGNORE_BACKEND: NATIVE // DONT_TARGET_EXACT_BACKEND: JS_IR fun box(): String { @@ -14,4 +13,4 @@ fun box(): String { } return "fail" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt index 135f715d24a..833e11a733a 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/boolean.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Boolean, y: Boolean) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/doubleInt.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/doubleInt.kt index cd7c43605f7..9818affbfba 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/doubleInt.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/doubleInt.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Double, y: Int) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/doubleLong.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/doubleLong.kt index 537833376ce..294560659ec 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/doubleLong.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/doubleLong.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Double, y: Long) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt index db632c2c05e..7ca0f34b787 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionArray.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Array, y: Array) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt index 2fe17a4ca33..1f355ed16e6 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/extensionObject.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR class A(val x: Int) operator fun A.compareTo(other: A) = x.compareTo(other.x) diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/intDouble.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/intDouble.kt index 132c63cd17d..a76709fe2db 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/intDouble.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/intDouble.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Int, y: Double) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/intLong.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/intLong.kt index d450971f3fb..dc91a1d0d51 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/intLong.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/intLong.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Int, y: Long) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/longDouble.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/longDouble.kt index 884a87d912a..90e43d49215 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/longDouble.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/longDouble.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Long, y: Double) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/operatorConventions/compareTo/longInt.kt b/compiler/testData/codegen/box/operatorConventions/compareTo/longInt.kt index 38bcfbb3dd5..623a3a46e01 100644 --- a/compiler/testData/codegen/box/operatorConventions/compareTo/longInt.kt +++ b/compiler/testData/codegen/box/operatorConventions/compareTo/longInt.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR fun checkLess(x: Long, y: Int) = when { x >= y -> "Fail $x >= $y" !(x < y) -> "Fail !($x < $y)" diff --git a/compiler/testData/codegen/box/primitiveTypes/kt3078.kt b/compiler/testData/codegen/box/primitiveTypes/kt3078.kt index 61a5e671193..cd834c89b2f 100644 --- a/compiler/testData/codegen/box/primitiveTypes/kt3078.kt +++ b/compiler/testData/codegen/box/primitiveTypes/kt3078.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - fun box(): String { if (1 >= 1.9) return "Fail #1" if (1.compareTo(1.1) >= 0) return "Fail #2" diff --git a/compiler/testData/ir/irText/expressions/conventionComparisons.fir.txt b/compiler/testData/ir/irText/expressions/conventionComparisons.fir.txt index b9c33f1c83a..ccdce811ae6 100644 --- a/compiler/testData/ir/irText/expressions/conventionComparisons.fir.txt +++ b/compiler/testData/ir/irText/expressions/conventionComparisons.fir.txt @@ -39,25 +39,45 @@ FILE fqName: fileName:/conventionComparisons.kt VALUE_PARAMETER name:a2 index:1 type:.IA BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (a1: .IA, a2: .IA): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: /IA' type=kotlin.Boolean + CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: CALL 'public abstract fun compareTo (other: .IA): kotlin.Int [operator] declared in .IB' type=kotlin.Int origin=null + $this: GET_VAR ': .IB declared in .test1' type=.IB origin=null + $receiver: GET_VAR 'a1: .IA declared in .test1' type=.IA origin=null + other: GET_VAR 'a2: .IA declared in .test1' type=.IA origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test2 visibility:public modality:FINAL <> ($receiver:.IB, a1:.IA, a2:.IA) returnType:kotlin.Boolean $receiver: VALUE_PARAMETER name: type:.IB VALUE_PARAMETER name:a1 index:0 type:.IA VALUE_PARAMETER name:a2 index:1 type:.IA BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (a1: .IA, a2: .IA): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: /IA' type=kotlin.Boolean + CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'public abstract fun compareTo (other: .IA): kotlin.Int [operator] declared in .IB' type=kotlin.Int origin=null + $this: GET_VAR ': .IB declared in .test2' type=.IB origin=null + $receiver: GET_VAR 'a1: .IA declared in .test2' type=.IA origin=null + other: GET_VAR 'a2: .IA declared in .test2' type=.IA origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test3 visibility:public modality:FINAL <> ($receiver:.IB, a1:.IA, a2:.IA) returnType:kotlin.Boolean $receiver: VALUE_PARAMETER name: type:.IB VALUE_PARAMETER name:a1 index:0 type:.IA VALUE_PARAMETER name:a2 index:1 type:.IA BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (a1: .IA, a2: .IA): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: /IA' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public abstract fun compareTo (other: .IA): kotlin.Int [operator] declared in .IB' type=kotlin.Int origin=null + $this: GET_VAR ': .IB declared in .test3' type=.IB origin=null + $receiver: GET_VAR 'a1: .IA declared in .test3' type=.IA origin=null + other: GET_VAR 'a2: .IA declared in .test3' type=.IA origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test4 visibility:public modality:FINAL <> ($receiver:.IB, a1:.IA, a2:.IA) returnType:kotlin.Boolean $receiver: VALUE_PARAMETER name: type:.IB VALUE_PARAMETER name:a1 index:0 type:.IA VALUE_PARAMETER name:a2 index:1 type:.IA BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (a1: .IA, a2: .IA): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: /IA' type=kotlin.Boolean + CALL 'public final fun lessOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'public abstract fun compareTo (other: .IA): kotlin.Int [operator] declared in .IB' type=kotlin.Int origin=null + $this: GET_VAR ': .IB declared in .test4' type=.IB origin=null + $receiver: GET_VAR 'a1: .IA declared in .test4' type=.IA origin=null + other: GET_VAR 'a2: .IA declared in .test4' type=.IA origin=null + arg1: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.fir.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.fir.txt index 416426b4cb4..95a5c8de757 100644 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.fir.txt +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.fir.txt @@ -111,7 +111,13 @@ FILE fqName: fileName:/floatingPointLess.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false - then: ERROR_CALL 'Comparison of arguments with different types: kotlin/Float, kotlin/Double' type=kotlin.Boolean + then: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Float' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'x: kotlin.Any declared in .testFD' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'y: kotlin.Any declared in .testFD' type=kotlin.Any origin=null + arg1: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false @@ -131,7 +137,13 @@ FILE fqName: fileName:/floatingPointLess.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false - then: ERROR_CALL 'Comparison of arguments with different types: kotlin/Double, kotlin/Float' type=kotlin.Boolean + then: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (other: kotlin.Float): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'x: kotlin.Any declared in .testDF' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'y: kotlin.Any declared in .testDF' type=kotlin.Any origin=null + arg1: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt index fafc14f76f5..6feca7245cc 100644 --- a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.fir.txt @@ -8,7 +8,12 @@ FILE fqName: fileName:/nullableAnyAsIntToDouble.kt BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Int GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - then: ERROR_CALL 'Comparison of arguments with different types: kotlin/Int, kotlin/Double' type=kotlin.Boolean + then: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int + GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null + other: GET_VAR 'y: kotlin.Double declared in .test' type=kotlin.Double origin=null + arg1: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/kt23030.fir.txt b/compiler/testData/ir/irText/expressions/kt23030.fir.txt index 54d6b4cfd37..084ef716e93 100644 --- a/compiler/testData/ir/irText/expressions/kt23030.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt23030.fir.txt @@ -10,7 +10,11 @@ FILE fqName: fileName:/kt23030.kt VALUE_PARAMETER name:y index:1 type:kotlin.Char BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testOverloadedCompareToCall (x: kotlin.Int, y: kotlin.Char): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with different types: kotlin/Int, kotlin/Char' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (c: kotlin.Char): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: GET_VAR 'x: kotlin.Int declared in .testOverloadedCompareToCall' type=kotlin.Int origin=null + c: GET_VAR 'y: kotlin.Char declared in .testOverloadedCompareToCall' type=kotlin.Char origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:testOverloadedCompareToCallWithSmartCast visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:kotlin.Boolean VALUE_PARAMETER name:x index:0 type:kotlin.Any VALUE_PARAMETER name:y index:1 type:kotlin.Any @@ -27,7 +31,13 @@ FILE fqName: fileName:/kt23030.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false - then: ERROR_CALL 'Comparison of arguments with different types: kotlin/Int, kotlin/Char' type=kotlin.Boolean + then: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (c: kotlin.Char): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int + GET_VAR 'x: kotlin.Any declared in .testOverloadedCompareToCallWithSmartCast' type=kotlin.Any origin=null + c: TYPE_OP type=kotlin.Char origin=IMPLICIT_CAST typeOperand=kotlin.Char + GET_VAR 'y: kotlin.Any declared in .testOverloadedCompareToCallWithSmartCast' type=kotlin.Any origin=null + arg1: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false @@ -74,7 +84,12 @@ FILE fqName: fileName:/kt23030.kt VALUE_PARAMETER name:y index:1 type:kotlin.Char BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testMemberExtensionCompareToCall (x: kotlin.Int, y: kotlin.Char): kotlin.Boolean declared in .C' - ERROR_CALL 'Comparison of arguments with different types: kotlin/Int, kotlin/Char' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (c: kotlin.Char): kotlin.Int [operator] declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C.testMemberExtensionCompareToCall' type=.C origin=null + $receiver: GET_VAR 'x: kotlin.Int declared in .C.testMemberExtensionCompareToCall' type=kotlin.Int origin=null + c: GET_VAR 'y: kotlin.Char declared in .C.testMemberExtensionCompareToCall' type=kotlin.Char origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:testMemberExtensionCompareToCallWithSmartCast visibility:public modality:FINAL <> ($this:.C, x:kotlin.Any, y:kotlin.Any) returnType:kotlin.Boolean $this: VALUE_PARAMETER name: type:.C VALUE_PARAMETER name:x index:0 type:kotlin.Any @@ -92,7 +107,14 @@ FILE fqName: fileName:/kt23030.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false - then: ERROR_CALL 'Comparison of arguments with different types: kotlin/Int, kotlin/Char' type=kotlin.Boolean + then: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (c: kotlin.Char): kotlin.Int [operator] declared in .C' type=kotlin.Int origin=null + $this: GET_VAR ': .C declared in .C.testMemberExtensionCompareToCallWithSmartCast' type=.C origin=null + $receiver: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int + GET_VAR 'x: kotlin.Any declared in .C.testMemberExtensionCompareToCallWithSmartCast' type=kotlin.Any origin=null + c: TYPE_OP type=kotlin.Char origin=IMPLICIT_CAST typeOperand=kotlin.Char + GET_VAR 'y: kotlin.Any declared in .C.testMemberExtensionCompareToCallWithSmartCast' type=kotlin.Any origin=null + arg1: CONST Int type=kotlin.Int value=0 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/primitiveComparisons.fir.txt b/compiler/testData/ir/irText/expressions/primitiveComparisons.fir.txt index e4cd920d1c8..4b3b441d206 100644 --- a/compiler/testData/ir/irText/expressions/primitiveComparisons.fir.txt +++ b/compiler/testData/ir/irText/expressions/primitiveComparisons.fir.txt @@ -4,49 +4,81 @@ FILE fqName: fileName:/primitiveComparisons.kt VALUE_PARAMETER name:b index:1 type:kotlin.Byte BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun btest1 (a: kotlin.Byte, b: kotlin.Byte): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Byte' type=kotlin.Boolean + CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: CALL 'public open fun compareTo (other: kotlin.Byte): kotlin.Int [operator] declared in kotlin.Byte' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Byte declared in .btest1' type=kotlin.Byte origin=null + other: GET_VAR 'b: kotlin.Byte declared in .btest1' type=kotlin.Byte origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:btest2 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Byte VALUE_PARAMETER name:b index:1 type:kotlin.Byte BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun btest2 (a: kotlin.Byte, b: kotlin.Byte): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Byte' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public open fun compareTo (other: kotlin.Byte): kotlin.Int [operator] declared in kotlin.Byte' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Byte declared in .btest2' type=kotlin.Byte origin=null + other: GET_VAR 'b: kotlin.Byte declared in .btest2' type=kotlin.Byte origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:btest3 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Byte VALUE_PARAMETER name:b index:1 type:kotlin.Byte BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun btest3 (a: kotlin.Byte, b: kotlin.Byte): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Byte' type=kotlin.Boolean + CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.Byte): kotlin.Int [operator] declared in kotlin.Byte' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Byte declared in .btest3' type=kotlin.Byte origin=null + other: GET_VAR 'b: kotlin.Byte declared in .btest3' type=kotlin.Byte origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:btest4 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Byte VALUE_PARAMETER name:b index:1 type:kotlin.Byte BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun btest4 (a: kotlin.Byte, b: kotlin.Byte): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Byte' type=kotlin.Boolean + CALL 'public final fun lessOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.Byte): kotlin.Int [operator] declared in kotlin.Byte' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Byte declared in .btest4' type=kotlin.Byte origin=null + other: GET_VAR 'b: kotlin.Byte declared in .btest4' type=kotlin.Byte origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:stest1 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Short VALUE_PARAMETER name:b index:1 type:kotlin.Short BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun stest1 (a: kotlin.Short, b: kotlin.Short): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Short' type=kotlin.Boolean + CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: CALL 'public open fun compareTo (other: kotlin.Short): kotlin.Int [operator] declared in kotlin.Short' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Short declared in .stest1' type=kotlin.Short origin=null + other: GET_VAR 'b: kotlin.Short declared in .stest1' type=kotlin.Short origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:stest2 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Short VALUE_PARAMETER name:b index:1 type:kotlin.Short BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun stest2 (a: kotlin.Short, b: kotlin.Short): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Short' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public open fun compareTo (other: kotlin.Short): kotlin.Int [operator] declared in kotlin.Short' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Short declared in .stest2' type=kotlin.Short origin=null + other: GET_VAR 'b: kotlin.Short declared in .stest2' type=kotlin.Short origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:stest3 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Short VALUE_PARAMETER name:b index:1 type:kotlin.Short BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun stest3 (a: kotlin.Short, b: kotlin.Short): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Short' type=kotlin.Boolean + CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.Short): kotlin.Int [operator] declared in kotlin.Short' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Short declared in .stest3' type=kotlin.Short origin=null + other: GET_VAR 'b: kotlin.Short declared in .stest3' type=kotlin.Short origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:stest4 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Short VALUE_PARAMETER name:b index:1 type:kotlin.Short BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun stest4 (a: kotlin.Short, b: kotlin.Short): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/Short' type=kotlin.Boolean + CALL 'public final fun lessOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.Short): kotlin.Int [operator] declared in kotlin.Short' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.Short declared in .stest4' type=kotlin.Short origin=null + other: GET_VAR 'b: kotlin.Short declared in .stest4' type=kotlin.Short origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:itest1 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.Int VALUE_PARAMETER name:b index:1 type:kotlin.Int diff --git a/compiler/testData/ir/irText/expressions/stringComparisons.fir.txt b/compiler/testData/ir/irText/expressions/stringComparisons.fir.txt index c2b5f66e84b..f09a8ea67a9 100644 --- a/compiler/testData/ir/irText/expressions/stringComparisons.fir.txt +++ b/compiler/testData/ir/irText/expressions/stringComparisons.fir.txt @@ -4,22 +4,38 @@ FILE fqName: fileName:/stringComparisons.kt VALUE_PARAMETER name:b index:1 type:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (a: kotlin.String, b: kotlin.String): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/String' type=kotlin.Boolean + CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: CALL 'public open fun compareTo (other: kotlin.String): kotlin.Int [operator] declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.String declared in .test1' type=kotlin.String origin=null + other: GET_VAR 'b: kotlin.String declared in .test1' type=kotlin.String origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.String) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.String VALUE_PARAMETER name:b index:1 type:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (a: kotlin.String, b: kotlin.String): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/String' type=kotlin.Boolean + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public open fun compareTo (other: kotlin.String): kotlin.Int [operator] declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.String declared in .test2' type=kotlin.String origin=null + other: GET_VAR 'b: kotlin.String declared in .test2' type=kotlin.String origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test3 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.String) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.String VALUE_PARAMETER name:b index:1 type:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (a: kotlin.String, b: kotlin.String): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/String' type=kotlin.Boolean + CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.String): kotlin.Int [operator] declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.String declared in .test3' type=kotlin.String origin=null + other: GET_VAR 'b: kotlin.String declared in .test3' type=kotlin.String origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:test4 visibility:public modality:FINAL <> (a:kotlin.String, b:kotlin.String) returnType:kotlin.Boolean VALUE_PARAMETER name:a index:0 type:kotlin.String VALUE_PARAMETER name:b index:1 type:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (a: kotlin.String, b: kotlin.String): kotlin.Boolean declared in ' - ERROR_CALL 'Comparison of arguments with unsupported type: kotlin/String' type=kotlin.Boolean + CALL 'public final fun lessOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'public open fun compareTo (other: kotlin.String): kotlin.Int [operator] declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_VAR 'a: kotlin.String declared in .test4' type=kotlin.String origin=null + other: GET_VAR 'b: kotlin.String declared in .test4' type=kotlin.String origin=null + arg1: CONST Int type=kotlin.Int value=0