diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt index a96ccbd3cc0..025fdc8e7c3 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt @@ -17,20 +17,28 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.IrTypeOperator -import org.jetbrains.kotlin.ir.expressions.impl.IrBinaryPrimitiveImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl -import org.jetbrains.kotlin.ir.expressions.impl.IrUnaryPrimitiveImpl +import org.jetbrains.kotlin.ir.expressions.impl.* +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.lexer.KtTokens +import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.psi2ir.findSingleFunction +import org.jetbrains.kotlin.psi2ir.intermediate.CallReceiver +import org.jetbrains.kotlin.psi2ir.intermediate.OnceExpressionValue +import org.jetbrains.kotlin.psi2ir.intermediate.SimpleCallReceiver import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberType import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import org.jetbrains.kotlin.types.typeUtil.makeNullable import java.lang.AssertionError @@ -150,8 +158,7 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat private fun generateInOperator(expression: KtBinaryExpression, irOperator: IrStatementOrigin): IrExpression { val containsCall = getResolvedCall(expression)!! - val irContainsCall = - CallGenerator(statementGenerator).generateCall(expression, statementGenerator.pregenerateCall(containsCall), irOperator) + val irContainsCall = generateCall(containsCall, expression, irOperator) return when (irOperator) { IrStatementOrigin.IN -> @@ -172,7 +179,6 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat val irArgument0 = statementGenerator.generateExpression(expression.left!!) val irArgument1 = statementGenerator.generateExpression(expression.right!!) - val irIdentityEquals = IrBinaryPrimitiveImpl( expression.startOffset, expression.endOffset, irOperator, context.irBuiltIns.eqeqeqSymbol, @@ -191,18 +197,33 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat else -> throw AssertionError("Unexpected identity operator $irOperator") } - } + private fun KtExpression.generateAsPrimitiveNumericComparisonOperand(primitiveNumericComparisonType: KotlinType?) = + statementGenerator.generateExpression(this) + .promoteToPrimitiveNumericType( + getPrimitiveNumericComparisonOperandType(this), + primitiveNumericComparisonType + ) + + private fun getPrimitiveNumericComparisonType(ktExpression: KtBinaryExpression) = + context.bindingContext[BindingContext.PRIMITIVE_NUMERIC_COMPARISON_TYPE, ktExpression] + + private fun getPrimitiveNumericComparisonOperandType(ktExpression: KtExpression) = + context.bindingContext[BindingContext.PRIMITIVE_NUMERIC_COMPARISON_OPERAND_TYPE, ktExpression] + private fun generateEqualityOperator(expression: KtBinaryExpression, irOperator: IrStatementOrigin): IrExpression { - val irArgument0 = statementGenerator.generateExpression(expression.left!!) - val irArgument1 = statementGenerator.generateExpression(expression.right!!) + val primitiveNumericComparisonType = getPrimitiveNumericComparisonType(expression) + + val eqeqSymbol = context.irBuiltIns.ieee754equalsFunByOperandType[primitiveNumericComparisonType]?.symbol + ?: context.irBuiltIns.eqeqSymbol val irEquals = IrBinaryPrimitiveImpl( expression.startOffset, expression.endOffset, irOperator, - context.irBuiltIns.eqeqSymbol, - irArgument0, irArgument1 + eqeqSymbol, + expression.left!!.generateAsPrimitiveNumericComparisonOperand(primitiveNumericComparisonType), + expression.right!!.generateAsPrimitiveNumericComparisonOperand(primitiveNumericComparisonType) ) return when (irOperator) { @@ -210,33 +231,104 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat irEquals IrStatementOrigin.EXCLEQ -> IrUnaryPrimitiveImpl( - expression.startOffset, expression.endOffset, IrStatementOrigin.EXCLEQ, + expression.startOffset, expression.endOffset, + IrStatementOrigin.EXCLEQ, context.irBuiltIns.booleanNotSymbol, irEquals ) else -> throw AssertionError("Unexpected equality operator $irOperator") } + } + private fun IrExpression.promoteToPrimitiveNumericType(operandType: KotlinType?, targetType: KotlinType?): IrExpression { + if (targetType == null) return this + if (operandType == null) throw AssertionError("operandType should be non-null") + + val operandNNType = operandType.makeNotNullable() + + val conversionFunction = operandNNType.findConversionFunctionTo(targetType) + + return when { + !operandNNType.isPrimitiveNumberType() -> + throw AssertionError("Primitive number type or nullable primitive number type expected: $type") + + operandType == targetType || operandNNType == targetType -> + this + + else -> + SimpleCallReceiver(OnceExpressionValue(this), null) + .invokeConversionFunction( + startOffset, endOffset, + conversionFunction ?: throw AssertionError("No conversion function for $type ~> $targetType") + ) + } + } + + private fun CallReceiver.invokeConversionFunction( + startOffset: Int, + endOffset: Int, + functionDescriptor: FunctionDescriptor + ): IrExpression = + call { dispatchReceiverValue, _ -> + IrCallImpl( + startOffset, + endOffset, + functionDescriptor.returnType!!, + context.symbolTable.referenceFunction(functionDescriptor.original), + functionDescriptor, + typeArguments = null, + origin = null, // TODO origin for widening conversions? + superQualifierSymbol = null + ).apply { + dispatchReceiver = dispatchReceiverValue!!.load() + } + } + + private fun KotlinType.findConversionFunctionTo(targetType: KotlinType): FunctionDescriptor? { + val targetTypeName = targetType.constructor.declarationDescriptor?.name?.asString() ?: return null + return memberScope.findSingleFunction(Name.identifier("to$targetTypeName")) } private fun generateComparisonOperator(expression: KtBinaryExpression, origin: IrStatementOrigin): IrExpression { - val compareToCall = getResolvedCall(expression)!! + val startOffset = expression.startOffset + val endOffset = expression.endOffset - val irCompareToCall = - CallGenerator(statementGenerator).generateCall(expression, statementGenerator.pregenerateCall(compareToCall), origin) + val primitiveNumberComparisonType = getPrimitiveNumericComparisonType(expression) - val compareToZeroSymbol = when (origin) { - IrStatementOrigin.LT -> context.irBuiltIns.lt0Symbol - IrStatementOrigin.LTEQ -> context.irBuiltIns.lteq0Symbol - IrStatementOrigin.GT -> context.irBuiltIns.gt0Symbol - IrStatementOrigin.GTEQ -> context.irBuiltIns.gteq0Symbol - else -> throw AssertionError("Unexpected comparison operator: $origin") + return if (primitiveNumberComparisonType != null) { + IrBinaryPrimitiveImpl( + startOffset, endOffset, origin, + getComparisonOperatorSymbol(origin, primitiveNumberComparisonType), + expression.left!!.generateAsPrimitiveNumericComparisonOperand(primitiveNumberComparisonType), + expression.right!!.generateAsPrimitiveNumericComparisonOperand(primitiveNumberComparisonType) + ) + } else { + IrBinaryPrimitiveImpl( + startOffset, endOffset, origin, + getComparisonOperatorSymbol(origin, context.irBuiltIns.int), + generateCall(getResolvedCall(expression)!!, expression, origin), + IrConstImpl.int(startOffset, endOffset, context.builtIns.intType, 0) + ) } - - return IrUnaryPrimitiveImpl(expression.startOffset, expression.endOffset, origin, compareToZeroSymbol, irCompareToCall) } + private fun generateCall( + resolvedCall: ResolvedCall<*>, + ktExpression: KtExpression, + origin: IrStatementOrigin? + ) = + CallGenerator(statementGenerator).generateCall(ktExpression, statementGenerator.pregenerateCall(resolvedCall), origin) + + private fun getComparisonOperatorSymbol(origin: IrStatementOrigin, primitiveNumericType: KotlinType): IrSimpleFunctionSymbol = + when (origin) { + IrStatementOrigin.LT -> context.irBuiltIns.lessFunByOperandType + IrStatementOrigin.LTEQ -> context.irBuiltIns.lessOrEqualFunByOperandType + IrStatementOrigin.GT -> context.irBuiltIns.greaterFunByOperandType + IrStatementOrigin.GTEQ -> context.irBuiltIns.greaterOrEqualFunByOperandType + else -> throw AssertionError("Unexpected comparison operator: $origin") + }[primitiveNumericType]!!.symbol + private fun generateExclExclOperator(expression: KtPostfixExpression, origin: IrStatementOrigin): IrExpression { val ktArgument = expression.baseExpression!! val irArgument = statementGenerator.generateExpression(ktArgument) @@ -250,10 +342,8 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat } } - private fun generateBinaryOperatorAsCall(expression: KtBinaryExpression, origin: IrStatementOrigin?): IrExpression { - val operatorCall = getResolvedCall(expression)!! - return CallGenerator(statementGenerator).generateCall(expression, statementGenerator.pregenerateCall(operatorCall), origin) - } + private fun generateBinaryOperatorAsCall(expression: KtBinaryExpression, origin: IrStatementOrigin?): IrExpression = + generateCall(getResolvedCall(expression)!!, expression, origin) private fun generatePrefixOperatorAsCall(expression: KtPrefixExpression, origin: IrStatementOrigin): IrExpression { val resolvedCall = getResolvedCall(expression)!! @@ -267,6 +357,6 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat } } - return CallGenerator(statementGenerator).generateCall(expression, statementGenerator.pregenerateCall(resolvedCall), origin) + return generateCall(resolvedCall, expression, origin) } } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/CallBuilder.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/CallBuilder.kt index cfebbc1e1fa..1a6834ff4ca 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/CallBuilder.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/CallBuilder.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.types.KotlinType class CallBuilder( - val original: ResolvedCall<*>, + val original: ResolvedCall<*>, // TODO get rid of "original", sometimes we want to generate a call without ResolvedCall val descriptor: CallableDescriptor, val isExtensionInvokeCall: Boolean = false ) { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt index 191cf9ea2ad..64f33582fd1 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrBuiltIns.kt @@ -32,7 +32,9 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.KotlinTypeFactory +import org.jetbrains.kotlin.types.SimpleType import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.typeUtil.makeNullable class IrBuiltIns(val builtIns: KotlinBuiltIns) { private val packageFragment = IrBuiltinsPackageFragmentDescriptorImpl(builtIns.builtInsModule, KOTLIN_INTERNAL_IR_FQN) @@ -59,40 +61,54 @@ class IrBuiltIns(val builtIns: KotlinBuiltIns) { private fun T.addStub(): IrSimpleFunction = addStubToPackageFragment(this) + private fun defineComparisonOperator(name: String, operandType: KotlinType) = + defineOperator(name, bool, listOf(operandType, operandType)) + + private fun List.defineComparisonOperatorForEachType(name: String) = + associate { it to defineComparisonOperator(name, it) } + val bool = builtIns.booleanType val any = builtIns.anyType val anyN = builtIns.nullableAnyType + val char = builtIns.charType + val byte = builtIns.byteType + val short = builtIns.shortType val int = builtIns.intType + val long = builtIns.longType + val float = builtIns.floatType + val double = builtIns.doubleType val nothing = builtIns.nothingType val unit = builtIns.unitType val string = builtIns.stringType + val primitiveTypes = listOf(bool, char, byte, short, int, long, float, double) + val primitiveTypesWithComparisons = listOf(int, long, float, double) + val primitiveFloatingPointTypes = listOf(float, double) + + val lessFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("less") + val lessOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("lessOrEqual") + val greaterOrEqualFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("greaterOrEqual") + val greaterFunByOperandType = primitiveTypesWithComparisons.defineComparisonOperatorForEachType("greater") + + val ieee754equalsFunByOperandType = + primitiveFloatingPointTypes.associate { + it to defineOperator("ieee754equals", bool, listOf(it.makeNullable(), it.makeNullable())) + } + val eqeqeqFun = defineOperator("EQEQEQ", bool, listOf(anyN, anyN)) val eqeqFun = defineOperator("EQEQ", bool, listOf(anyN, anyN)) - val lt0Fun = defineOperator("LT0", bool, listOf(int)) - val lteq0Fun = defineOperator("LTEQ0", bool, listOf(int)) - val gt0Fun = defineOperator("GT0", bool, listOf(int)) - val gteq0Fun = defineOperator("GTEQ0", bool, listOf(int)) val throwNpeFun = defineOperator("THROW_NPE", nothing, listOf()) val booleanNotFun = defineOperator("NOT", bool, listOf(bool)) val noWhenBranchMatchedExceptionFun = defineOperator("noWhenBranchMatchedException", unit, listOf()) val eqeqeq = eqeqeqFun.descriptor val eqeq = eqeqFun.descriptor - val lt0 = lt0Fun.descriptor - val lteq0 = lteq0Fun.descriptor - val gt0 = gt0Fun.descriptor - val gteq0 = gteq0Fun.descriptor val throwNpe = throwNpeFun.descriptor val booleanNot = booleanNotFun.descriptor val noWhenBranchMatchedException = noWhenBranchMatchedExceptionFun.descriptor val eqeqeqSymbol = eqeqeqFun.symbol val eqeqSymbol = eqeqFun.symbol - val lt0Symbol = lt0Fun.symbol - val lteq0Symbol = lteq0Fun.symbol - val gt0Symbol = gt0Fun.symbol - val gteq0Symbol = gteq0Fun.symbol val throwNpeSymbol = throwNpeFun.symbol val booleanNotSymbol = booleanNotFun.symbol val noWhenBranchMatchedExceptionSymbol = noWhenBranchMatchedExceptionFun.symbol diff --git a/compiler/testData/ir/irCfg/loop/digitCount.txt b/compiler/testData/ir/irCfg/loop/digitCount.txt index 027fc394a6a..d124bed4225 100644 --- a/compiler/testData/ir/irCfg/loop/digitCount.txt +++ b/compiler/testData/ir/irCfg/loop/digitCount.txt @@ -39,18 +39,17 @@ CONTENT 1 SET_VAR 'number: Int' type=kotlin.Unit origin=DIVEQ 2 GET_VAR 'number: Int' type=kotlin.Int origin=null 3 CONST Int type=kotlin.Int value=0 - 4 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT OUTGOING -> BB 4, 5 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT BB 4 INCOMING <- BB 3 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT OUTGOING -> BB 1 Do..while entry: DO_WHILE label=null origin=DO_WHILE_LOOP BB 5 INCOMING <- BB 3 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT OUTGOING -> BB 6 Do..while exit: DO_WHILE label=null origin=DO_WHILE_LOOP diff --git a/compiler/testData/ir/irCfg/loop/isPerfect.txt b/compiler/testData/ir/irCfg/loop/isPerfect.txt index 40215cb96f4..bec2f7c37b0 100644 --- a/compiler/testData/ir/irCfg/loop/isPerfect.txt +++ b/compiler/testData/ir/irCfg/loop/isPerfect.txt @@ -34,37 +34,35 @@ CONTENT 6 GET_VAR 'm: Int' type=kotlin.Int origin=null 7 CALL 'rem(Int): Int' type=kotlin.Int origin=PERC 8 CONST Int type=kotlin.Int value=0 - 9 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT OUTGOING -> BB 3, 4 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT BB 3 INCOMING <- BB 2 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 CONTINUE label=null loop.label=null OUTGOING -> BB 1 While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE BB 4 INCOMING <- BB 2 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 SET_VAR 'sum: Int' type=kotlin.Unit origin=PLUSEQ 2 WHEN type=kotlin.Unit origin=null 3 GET_VAR 'sum: Int' type=kotlin.Int origin=null 4 GET_VAR 'value-parameter n: Int' type=kotlin.Int origin=null - 5 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT OUTGOING -> BB 5, 6 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT BB 5 INCOMING <- BB 4 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 BREAK label=null loop.label=null OUTGOING -> BB 8 While exit: WHILE label=null origin=FOR_LOOP_INNER_WHILE BB 6 INCOMING <- BB 4 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT OUTGOING -> BB 1 While entry: WHILE label=null origin=FOR_LOOP_INNER_WHILE diff --git a/compiler/testData/ir/irCfg/when/cascadeIf.txt b/compiler/testData/ir/irCfg/when/cascadeIf.txt index dc96da1545c..454296ce462 100644 --- a/compiler/testData/ir/irCfg/when/cascadeIf.txt +++ b/compiler/testData/ir/irCfg/when/cascadeIf.txt @@ -6,34 +6,32 @@ CONTENT 2 WHEN type=kotlin.Int origin=WHEN 3 GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null 4 GET_VAR 'value-parameter y: Int' type=kotlin.Int origin=null - 5 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT OUTGOING -> BB 1, 3 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT BB 1 INCOMING <- BB 0 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null 2 GET_VAR 'value-parameter y: Int' type=kotlin.Int origin=null - 3 CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT OUTGOING -> BB 2, 4 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT BB 2 INCOMING <- BB 1 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT CONTENT OUTGOING -> BB 5 CONST Boolean type=kotlin.Boolean value=true BB 3 INCOMING <- BB 0 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 CONST Int type=kotlin.Int value=1 OUTGOING -> BB 6 When exit: WHEN type=kotlin.Int origin=WHEN BB 4 INCOMING <- BB 1 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 CONST Int type=kotlin.Int value=-1 OUTGOING -> BB 6 diff --git a/compiler/testData/ir/irCfg/when/expressionIf.txt b/compiler/testData/ir/irCfg/when/expressionIf.txt index a0670dca45e..68f7020a163 100644 --- a/compiler/testData/ir/irCfg/when/expressionIf.txt +++ b/compiler/testData/ir/irCfg/when/expressionIf.txt @@ -6,18 +6,17 @@ CONTENT 2 WHEN type=kotlin.Int origin=null 3 GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null 4 GET_VAR 'value-parameter y: Int' type=kotlin.Int origin=null - 5 CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT OUTGOING -> BB 1, 2 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT BB 1 INCOMING <- BB 0 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT OUTGOING -> BB 3 CONST Boolean type=kotlin.Boolean value=true BB 2 INCOMING <- BB 0 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null OUTGOING -> BB 4 diff --git a/compiler/testData/ir/irCfg/when/ifChain.txt b/compiler/testData/ir/irCfg/when/ifChain.txt index f745895bddd..a4e699e0b33 100644 --- a/compiler/testData/ir/irCfg/when/ifChain.txt +++ b/compiler/testData/ir/irCfg/when/ifChain.txt @@ -7,19 +7,19 @@ CONTENT 3 GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null 4 CONST Double type=kotlin.Double value=0.0 OUTGOING -> BB 1, 6 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ BB 1 INCOMING <- BB 0 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ CONTENT 1 WHEN type=kotlin.Unit origin=null 2 GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null 3 CONST Double type=kotlin.Double value=0.0 OUTGOING -> BB 2, 3 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ BB 2 INCOMING <- BB 1 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ CONTENT 1 CONST Double type=kotlin.Double value=1.0 2 RETURN type=kotlin.Nothing from='minBiRoot(Double, Double, Double): Double' @@ -27,7 +27,7 @@ OUTGOING -> NONE Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:Double flags: BB 3 INCOMING <- BB 1 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ CONTENT 1 GET_VAR 'value-parameter c: Double' type=kotlin.Double origin=null 2 CALL 'unaryMinus(): Double' type=kotlin.Double origin=UMINUS @@ -37,12 +37,11 @@ CONTENT 6 WHEN type=kotlin.Unit origin=null 7 GET_VAR 'bc: Double' type=kotlin.Double origin=null 8 CONST Double type=kotlin.Double value=0.0 - 9 CALL 'compareTo(Double): Int' type=kotlin.Int origin=LT OUTGOING -> BB 4, 5 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT BB 4 INCOMING <- BB 3 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 CONST Double type=kotlin.Double value=2.0 2 RETURN type=kotlin.Nothing from='minBiRoot(Double, Double, Double): Double' @@ -50,7 +49,7 @@ OUTGOING -> NONE Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:Double flags: BB 5 INCOMING <- BB 3 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 GET_VAR 'bc: Double' type=kotlin.Double origin=null 2 CALL 'unaryMinus(): Double' type=kotlin.Double origin=UMINUS @@ -59,7 +58,7 @@ OUTGOING -> NONE Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:Double flags: BB 6 INCOMING <- BB 0 - CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ CONTENT 1 GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null 2 GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null @@ -74,12 +73,11 @@ CONTENT 11 WHEN type=kotlin.Unit origin=null 12 GET_VAR 'd: Double' type=kotlin.Double origin=null 13 CONST Double type=kotlin.Double value=0.0 - 14 CALL 'compareTo(Double): Int' type=kotlin.Int origin=LT OUTGOING -> BB 7, 8 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT BB 7 INCOMING <- BB 6 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 CONST Double type=kotlin.Double value=3.0 2 RETURN type=kotlin.Nothing from='minBiRoot(Double, Double, Double): Double' @@ -87,7 +85,7 @@ OUTGOING -> NONE Function exit: FUN name:minBiRoot visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double, c:kotlin.Double) returnType:Double flags: BB 8 INCOMING <- BB 6 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null 2 CALL 'unaryMinus(): Double' type=kotlin.Double origin=UMINUS @@ -110,18 +108,17 @@ CONTENT 19 WHEN type=kotlin.Double origin=null 20 GET_VAR 'y1: Double' type=kotlin.Double origin=null 21 GET_VAR 'y2: Double' type=kotlin.Double origin=null - 22 CALL 'compareTo(Double): Int' type=kotlin.Int origin=GT OUTGOING -> BB 9, 10 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Double, Double): Boolean' type=kotlin.Boolean origin=GT BB 9 INCOMING <- BB 8 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Double, Double): Boolean' type=kotlin.Boolean origin=GT CONTENT OUTGOING -> BB 11 CONST Boolean type=kotlin.Boolean value=true BB 10 INCOMING <- BB 8 - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Double, Double): Boolean' type=kotlin.Boolean origin=GT CONTENT 1 GET_VAR 'y1: Double' type=kotlin.Double origin=null OUTGOING -> BB 12 @@ -141,18 +138,17 @@ CONTENT 2 WHEN type=kotlin.Double origin=null 3 GET_VAR 'y3: Double' type=kotlin.Double origin=null 4 CONST Double type=kotlin.Double value=0.0 - 5 CALL 'compareTo(Double): Int' type=kotlin.Int origin=LT OUTGOING -> BB 13, 14 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT BB 13 INCOMING <- BB 12 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT OUTGOING -> BB 15 CONST Boolean type=kotlin.Boolean value=true BB 14 INCOMING <- BB 12 - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT CONTENT 1 CONST Double type=kotlin.Double value=4.0 OUTGOING -> BB 16 diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt index bdbf962569c..46b57206cf3 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt @@ -119,10 +119,9 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt GET_VAR 'j: Int' type=kotlin.Int origin=PREFIX_INCR condition: WHEN type=kotlin.Boolean origin=null BRANCH - if: CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GTEQ - $this: GET_VAR 'j: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=3 + if: CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'j: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=3 then: CONST Boolean type=kotlin.Boolean value=false BRANCH if: CONST Boolean type=kotlin.Boolean value=true @@ -133,4 +132,3 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt arg0: GET_VAR 'i: Int' type=kotlin.Int origin=null arg1: CONST Int type=kotlin.Int value=3 then: BREAK label=null loop.label=Outer - diff --git a/compiler/testData/ir/irText/expressions/conventionComparisons.txt b/compiler/testData/ir/irText/expressions/conventionComparisons.txt index 2d1885f36c1..e6f365cf271 100644 --- a/compiler/testData/ir/irText/expressions/conventionComparisons.txt +++ b/compiler/testData/ir/irText/expressions/conventionComparisons.txt @@ -27,42 +27,45 @@ FILE fqName: fileName:/conventionComparisons.kt VALUE_PARAMETER name:a2 index:1 type:IA flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test1(IA, IA) on IB: Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT arg0: CALL 'compareTo(IA) on IA: Int' type=kotlin.Int origin=GT $this: GET_VAR 'this@test1: IB' type=IB origin=null $receiver: GET_VAR 'value-parameter a1: IA' type=IA origin=null other: GET_VAR 'value-parameter a2: IA' 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:Boolean flags: $receiver: VALUE_PARAMETER name: type:IB flags: VALUE_PARAMETER name:a1 index:0 type:IA flags: VALUE_PARAMETER name:a2 index:1 type:IA flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test2(IA, IA) on IB: Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ + CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ arg0: CALL 'compareTo(IA) on IA: Int' type=kotlin.Int origin=GTEQ $this: GET_VAR 'this@test2: IB' type=IB origin=null $receiver: GET_VAR 'value-parameter a1: IA' type=IA origin=null other: GET_VAR 'value-parameter a2: IA' 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:Boolean flags: $receiver: VALUE_PARAMETER name: type:IB flags: VALUE_PARAMETER name:a1 index:0 type:IA flags: VALUE_PARAMETER name:a2 index:1 type:IA flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test3(IA, IA) on IB: Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT arg0: CALL 'compareTo(IA) on IA: Int' type=kotlin.Int origin=LT $this: GET_VAR 'this@test3: IB' type=IB origin=null $receiver: GET_VAR 'value-parameter a1: IA' type=IA origin=null other: GET_VAR 'value-parameter a2: IA' 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:Boolean flags: $receiver: VALUE_PARAMETER name: type:IB flags: VALUE_PARAMETER name:a1 index:0 type:IA flags: VALUE_PARAMETER name:a2 index:1 type:IA flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test4(IA, IA) on IB: Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ + CALL 'lessOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=LTEQ arg0: CALL 'compareTo(IA) on IA: Int' type=kotlin.Int origin=LTEQ $this: GET_VAR 'this@test4: IB' type=IB origin=null $receiver: GET_VAR 'value-parameter a1: IA' type=IA origin=null other: GET_VAR 'value-parameter a2: IA' type=IA origin=null - + arg1: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt new file mode 100644 index 00000000000..0c1cc53e4ce --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt @@ -0,0 +1,3 @@ +fun testD(x: Comparable, y: Comparable) = x is Double && y is Double && x < y + +fun testF(x: Comparable, y: Comparable) = x is Float && y is Float && x < y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.txt new file mode 100644 index 00000000000..d5443abb05e --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.txt @@ -0,0 +1,49 @@ +FILE fqName: fileName:/comparableWithDoubleOrFloat.kt + FUN name:testD visibility:public modality:FINAL <> (x:kotlin.Comparable, y:kotlin.Comparable) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Comparable flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Comparable flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testD(Comparable, Comparable): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Comparable' type=kotlin.Comparable origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Comparable' type=kotlin.Comparable origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Comparable' type=kotlin.Comparable origin=null + arg1: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Comparable' type=kotlin.Comparable origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testF visibility:public modality:FINAL <> (x:kotlin.Comparable, y:kotlin.Comparable) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Comparable flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Comparable flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testF(Comparable, Comparable): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Comparable' type=kotlin.Comparable origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Comparable' type=kotlin.Comparable origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Float, Float): Boolean' type=kotlin.Boolean origin=LT + arg0: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Comparable' type=kotlin.Comparable origin=null + arg1: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Comparable' type=kotlin.Comparable origin=null + 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/floatingPointCompareTo.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt new file mode 100644 index 00000000000..f4f8b1af849 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt @@ -0,0 +1,14 @@ +fun test1d(x: Double, y: Double) = x.compareTo(y) +fun test2d(x: Double, y: Any) = y is Double && x.compareTo(y) == 0 +fun test3d(x: Any, y: Any) = x is Double && y is Double && x.compareTo(y) == 0 + +fun test1f(x: Float, y: Float) = x.compareTo(y) +fun test2f(x: Float, y: Any) = y is Float && x.compareTo(y) == 0 +fun test3f(x: Any, y: Any) = x is Float && y is Float && x.compareTo(y) == 0 + +fun testFD(x: Any, y: Any) = x is Float && y is Double && x.compareTo(y) == 0 +fun testDF(x: Any, y: Any) = x is Double && y is Float && x.compareTo(y) == 0 + +fun Float.test1fr(x: Float) = compareTo(x) +fun Float.test2fr(x: Any) = x is Float && compareTo(x) == 0 +fun Float.test3fr(x: Any) = x is Double && compareTo(x) == 0 \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.txt new file mode 100644 index 00000000000..652c8c8e01f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.txt @@ -0,0 +1,201 @@ +FILE fqName: fileName:/floatingPointCompareTo.kt + FUN name:test1d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double) returnType:Int flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1d(Double, Double): Int' + CALL 'compareTo(Double): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + FUN name:test2d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2d(Double, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' 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 + FUN name:test3d visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3d(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' 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 + FUN name:test1f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float) returnType:Int flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1f(Float, Float): Int' + CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Float' type=kotlin.Float origin=null + FUN name:test2f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2f(Float, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' 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 + FUN name:test3f visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3f(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' 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 + FUN name:testFD visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testFD(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' 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 + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' 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 + FUN name:test1fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Float) returnType:Int flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1fr(Float) on Float: Int' + CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: GET_VAR 'this@test1fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + FUN name:test2fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Any) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2fr(Any) on Float: Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=null + $this: GET_VAR 'this@test2fr: Float' type=kotlin.Float origin=null + other: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' 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 + FUN name:test3fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Any) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3fr(Any) on Float: Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=null + $this: GET_VAR 'this@test3fr: Float' type=kotlin.Float origin=null + other: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' 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/floatingPointEqeq.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.kt new file mode 100644 index 00000000000..67424934619 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.kt @@ -0,0 +1,18 @@ +fun test1d(x: Double, y: Double) = x == y +fun test2d(x: Double, y: Double?) = x == y +fun test3d(x: Double, y: Any) = x == y +fun test4d(x: Double, y: Number) = x == y +fun test5d(x: Double, y: Any) = y is Double && x == y +fun test6d(x: Any, y: Any) = x is Double && y is Double && x == y + +fun test1f(x: Float, y: Float) = x == y +fun test2f(x: Float, y: Float?) = x == y +fun test3f(x: Float, y: Any) = x == y +fun test4f(x: Float, y: Number) = x == y +fun test5f(x: Float, y: Any) = y is Float && x == y +fun test6f(x: Any, y: Any) = x is Float && y is Float && x == y + +// The following possibly should not compile (but so far it does) +// because of EQUALITY_NOT_APPLICABLE. +fun testFD(x: Any, y: Any) = x is Float && y is Double && x == y +fun testDF(x: Any, y: Any) = x is Double && y is Float && x == y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.txt new file mode 100644 index 00000000000..30bc23179d6 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.txt @@ -0,0 +1,195 @@ +FILE fqName: fileName:/floatingPointEqeq.kt + FUN name:test1d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1d(Double, Double): Boolean' + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + FUN name:test2d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2d(Double, Double?): Boolean' + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Double?' type=kotlin.Double? origin=null + FUN name:test3d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3d(Double, Any): Boolean' + CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4d(Double, Number): Boolean' + CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5d(Double, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6d visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6d(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test1f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1f(Float, Float): Boolean' + CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Float' type=kotlin.Float origin=null + FUN name:test2f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2f(Float, Float?): Boolean' + CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Float?' type=kotlin.Float? origin=null + FUN name:test3f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3f(Float, Any): Boolean' + CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4f(Float, Number): Boolean' + CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5f(Float, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6f visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6f(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testFD visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testFD(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + 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/floatingPointEquals.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.kt new file mode 100644 index 00000000000..17bbaaa72f7 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.kt @@ -0,0 +1,23 @@ +fun test1d(x: Double, y: Double) = x.equals(y) +fun test2d(x: Double, y: Double?) = x.equals(y) +fun test3d(x: Double, y: Any) = x.equals(y) +fun test4d(x: Double, y: Number) = x.equals(y) +fun test5d(x: Double, y: Any) = y is Double && x.equals(y) +fun test6d(x: Any, y: Any) = x is Double && y is Double && x.equals(y) + +fun test1f(x: Float, y: Float) = x.equals(y) +fun test2f(x: Float, y: Float?) = x.equals(y) +fun test3f(x: Float, y: Any) = x.equals(y) +fun test4f(x: Float, y: Number) = x.equals(y) +fun test5f(x: Float, y: Any) = y is Float && x.equals(y) +fun test6f(x: Any, y: Any) = x is Float && y is Float && x.equals(y) + +fun testFD(x: Any, y: Any) = x is Float && y is Double && x.equals(y) +fun testDF(x: Any, y: Any) = x is Double && y is Float && x.equals(y) + +fun Float.test1fr(x: Float) = equals(x) +fun Float.test2fr(x: Float?) = equals(x) +fun Float.test3fr(x: Any) = equals(x) +fun Float.test4fr(x: Number) = equals(x) +fun Float.test5fr(x: Any) = x is Float && equals(x) +fun Float.test6fr(x: Any) = x is Double && equals(x) \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.txt new file mode 100644 index 00000000000..7c6b9225588 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.txt @@ -0,0 +1,245 @@ +FILE fqName: fileName:/floatingPointEquals.kt + FUN name:test1d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1d(Double, Double): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + FUN name:test2d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2d(Double, Double?): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Double?' type=kotlin.Double? origin=null + FUN name:test3d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3d(Double, Any): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4d(Double, Number): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5d(Double, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6d visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6d(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test1f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1f(Float, Float): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Float' type=kotlin.Float origin=null + FUN name:test2f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2f(Float, Float?): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Float?' type=kotlin.Float? origin=null + FUN name:test3f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3f(Float, Any): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4f(Float, Number): Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5f(Float, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6f visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6f(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testFD visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testFD(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + other: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test1fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Float) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1fr(Float) on Float: Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test1fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + FUN name:test2fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Float?) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2fr(Float?) on Float: Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test2fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Float?' type=kotlin.Float? origin=null + FUN name:test3fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Any) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3fr(Any) on Float: Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test3fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + FUN name:test4fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Number) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4fr(Number) on Float: Boolean' + CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test4fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Number' type=kotlin.Number origin=null + FUN name:test5fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Any) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5fr(Any) on Float: Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test5fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6fr visibility:public modality:FINAL <> ($receiver:kotlin.Float, x:kotlin.Any) returnType:Boolean flags: + $receiver: VALUE_PARAMETER name: type:kotlin.Float flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6fr(Any) on Float: Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'this@test6fr: Float' type=kotlin.Float origin=null + other: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + 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/floatingPointExcleq.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.kt new file mode 100644 index 00000000000..2d853a016f1 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.kt @@ -0,0 +1,18 @@ +fun test1d(x: Double, y: Double) = x != y +fun test2d(x: Double, y: Double?) = x != y +fun test3d(x: Double, y: Any) = x != y +fun test4d(x: Double, y: Number) = x != y +fun test5d(x: Double, y: Any) = y is Double && x != y +fun test6d(x: Any, y: Any) = x is Double && y is Double && x != y + +fun test1f(x: Float, y: Float) = x != y +fun test2f(x: Float, y: Float?) = x != y +fun test3f(x: Float, y: Any) = x != y +fun test4f(x: Float, y: Number) = x != y +fun test5f(x: Float, y: Any) = y is Float && x != y +fun test6f(x: Any, y: Any) = x is Float && y is Float && x != y + +// The following possibly should not compile (but so far it does) +// because of EQUALITY_NOT_APPLICABLE. +fun testFD(x: Any, y: Any) = x is Float && y is Double && x != y +fun testDF(x: Any, y: Any) = x is Double && y is Float && x != y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.txt new file mode 100644 index 00000000000..631a7a2d660 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.txt @@ -0,0 +1,209 @@ +FILE fqName: fileName:/floatingPointExcleq.kt + FUN name:test1d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1d(Double, Double): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + FUN name:test2d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2d(Double, Double?): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Double?' type=kotlin.Double? origin=null + FUN name:test3d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3d(Double, Any): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4d(Double, Number): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5d(Double, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6d visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6d(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test1f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1f(Float, Float): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Float' type=kotlin.Float origin=null + FUN name:test2f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2f(Float, Float?): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Float?' type=kotlin.Float? origin=null + FUN name:test3f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3f(Float, Any): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + FUN name:test4f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Number) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Number flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test4f(Float, Number): Boolean' + CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Number' type=kotlin.Number origin=null + FUN name:test5f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test5f(Float, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test6f visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test6f(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Float?, Float?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Float? origin=IMPLICIT_CAST typeOperand=kotlin.Float? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testFD visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testFD(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: TYPE_OP type=kotlin.Double? origin=IMPLICIT_CAST typeOperand=kotlin.Double? + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + 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/floatingPointLess.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.kt new file mode 100644 index 00000000000..0024bfe4846 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.kt @@ -0,0 +1,10 @@ +fun test1d(x: Double, y: Double) = x < y +fun test2d(x: Double, y: Any) = y is Double && x < y +fun test3d(x: Any, y: Any) = x is Double && y is Double && x < y + +fun test1f(x: Float, y: Float) = x < y +fun test2f(x: Float, y: Any) = y is Float && x < y +fun test3f(x: Any, y: Any) = x is Float && y is Float && x < y + +fun testFD(x: Any, y: Any) = x is Float && y is Double && x < y +fun testDF(x: Any, y: Any) = x is Double && y is Float && x < y diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.txt new file mode 100644 index 00000000000..a9aebbf4efc --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.txt @@ -0,0 +1,147 @@ +FILE fqName: fileName:/floatingPointLess.kt + FUN name:test1d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Double) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1d(Double, Double): Boolean' + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + FUN name:test2d visibility:public modality:FINAL <> (x:kotlin.Double, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2d(Double, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter x: Double' type=kotlin.Double origin=null + arg1: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test3d visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3d(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test1f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Float) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Float flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test1f(Float, Float): Boolean' + CALL 'less(Float, Float): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter y: Float' type=kotlin.Float origin=null + FUN name:test2f visibility:public modality:FINAL <> (x:kotlin.Float, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Float flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test2f(Float, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + then: CALL 'less(Float, Float): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter x: Float' type=kotlin.Float origin=null + arg1: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:test3f visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test3f(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Float, Float): Boolean' type=kotlin.Boolean origin=LT + arg0: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testFD visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testFD(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Any, y:kotlin.Any) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Any, Any): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: TYPE_OP type=kotlin.Double origin=IMPLICIT_CAST typeOperand=kotlin.Double + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + arg1: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any' type=kotlin.Any origin=null + 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.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt new file mode 100644 index 00000000000..ecbdc6d17aa --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt @@ -0,0 +1,2 @@ +fun test(x: Any?, y: Double) = + x is Int && x < y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.txt new file mode 100644 index 00000000000..ed9d9209221 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/nullableAnyAsIntToDouble.kt + FUN name:test visibility:public modality:FINAL <> (x:kotlin.Any?, y:kotlin.Double) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Any? flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='test(Any?, Double): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Int + GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + then: CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int + GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + arg1: GET_VAR 'value-parameter y: Double' type=kotlin.Double origin=null + 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/nullableFloatingPointEqeq.kt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.kt new file mode 100644 index 00000000000..325db51921a --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.kt @@ -0,0 +1,3 @@ +fun testDD(x: Double?, y: Double?) = x == y +fun testDF(x: Double?, y: Any?) = y is Float? && x == y +fun testDI(x: Double?, y: Any?) = y is Int? && x == y \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.txt b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.txt new file mode 100644 index 00000000000..6f913e6b43d --- /dev/null +++ b/compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.txt @@ -0,0 +1,43 @@ +FILE fqName: fileName:/nullableFloatingPointEqeq.kt + FUN name:testDD visibility:public modality:FINAL <> (x:kotlin.Double?, y:kotlin.Double?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double? flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Double? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDD(Double?, Double?): Boolean' + CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double?' type=kotlin.Double? origin=null + arg1: GET_VAR 'value-parameter y: Double?' type=kotlin.Double? origin=null + FUN name:testDF visibility:public modality:FINAL <> (x:kotlin.Double?, y:kotlin.Any?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double? flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDF(Double?, Any?): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Float? + GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double?' type=kotlin.Double? origin=null + arg1: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Float origin=IMPLICIT_CAST typeOperand=kotlin.Float + GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + FUN name:testDI visibility:public modality:FINAL <> (x:kotlin.Double?, y:kotlin.Any?) returnType:Boolean flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Double? flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Any? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='testDI(Double?, Any?): Boolean' + WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.Int? + GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null + then: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Double?' type=kotlin.Double? origin=null + arg1: CALL 'toDouble(): Double' type=kotlin.Double origin=null + $this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int + GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null + 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/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt index de3a968cee6..79d872c4a85 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt @@ -57,11 +57,10 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt $receiver: VALUE_PARAMETER name: type:IntCell flags: BLOCK_BODY RETURN type=kotlin.Nothing from='hasNext() on IntCell: Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT - $this: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'this@hasNext: IntCell' type=IntCell origin=null - other: CONST Int type=kotlin.Int value=0 + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT + arg0: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'this@hasNext: IntCell' type=IntCell origin=null + arg1: CONST Int type=kotlin.Int value=0 FUN name:next visibility:public modality:OPEN <> ($this:IReceiver, $receiver:IntCell) returnType:Int flags: $this: VALUE_PARAMETER name: type:IReceiver flags: $receiver: VALUE_PARAMETER name: type:IntCell flags: @@ -106,4 +105,3 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt BLOCK type=kotlin.Unit origin=null CALL 'println(Int): Unit' type=kotlin.Unit origin=null message: GET_VAR 'i: Int' type=kotlin.Int origin=null - diff --git a/compiler/testData/ir/irText/expressions/ifElseIf.txt b/compiler/testData/ir/irText/expressions/ifElseIf.txt index e260cf8ac10..03dd3bf893d 100644 --- a/compiler/testData/ir/irText/expressions/ifElseIf.txt +++ b/compiler/testData/ir/irText/expressions/ifElseIf.txt @@ -5,18 +5,15 @@ FILE fqName: fileName:/ifElseIf.kt RETURN type=kotlin.Nothing from='test(Int): Int' WHEN type=kotlin.Int origin=WHEN BRANCH - if: CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=0 + if: CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 then: CONST Int type=kotlin.Int value=1 BRANCH - if: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=0 + if: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 then: CONST Int type=kotlin.Int value=-1 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CONST Int type=kotlin.Int value=0 - diff --git a/compiler/testData/ir/irText/expressions/primitiveComparisons.txt b/compiler/testData/ir/irText/expressions/primitiveComparisons.txt index 5225c1658a0..3c1682a8a9a 100644 --- a/compiler/testData/ir/irText/expressions/primitiveComparisons.txt +++ b/compiler/testData/ir/irText/expressions/primitiveComparisons.txt @@ -4,215 +4,206 @@ FILE fqName: fileName:/primitiveComparisons.kt VALUE_PARAMETER name:b index:1 type:kotlin.Byte flags: BLOCK_BODY RETURN type=kotlin.Nothing from='btest1(Byte, Byte): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Byte): Int' type=kotlin.Int origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Byte' type=kotlin.Byte origin=null - other: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null FUN name:btest2 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Byte flags: VALUE_PARAMETER name:b index:1 type:kotlin.Byte flags: BLOCK_BODY RETURN type=kotlin.Nothing from='btest2(Byte, Byte): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Byte): Int' type=kotlin.Int origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Byte' type=kotlin.Byte origin=null - other: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null FUN name:btest3 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Byte flags: VALUE_PARAMETER name:b index:1 type:kotlin.Byte flags: BLOCK_BODY RETURN type=kotlin.Nothing from='btest3(Byte, Byte): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Byte): Int' type=kotlin.Int origin=GTEQ + CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Byte' type=kotlin.Byte origin=null - other: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null FUN name:btest4 visibility:public modality:FINAL <> (a:kotlin.Byte, b:kotlin.Byte) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Byte flags: VALUE_PARAMETER name:b index:1 type:kotlin.Byte flags: BLOCK_BODY RETURN type=kotlin.Nothing from='btest4(Byte, Byte): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Byte): Int' type=kotlin.Int origin=LTEQ + CALL 'lessOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Byte' type=kotlin.Byte origin=null - other: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Byte' type=kotlin.Byte origin=null FUN name:stest1 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Short flags: VALUE_PARAMETER name:b index:1 type:kotlin.Short flags: BLOCK_BODY RETURN type=kotlin.Nothing from='stest1(Short, Short): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Short): Int' type=kotlin.Int origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Short' type=kotlin.Short origin=null - other: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null FUN name:stest2 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Short flags: VALUE_PARAMETER name:b index:1 type:kotlin.Short flags: BLOCK_BODY RETURN type=kotlin.Nothing from='stest2(Short, Short): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Short): Int' type=kotlin.Int origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Short' type=kotlin.Short origin=null - other: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null FUN name:stest3 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Short flags: VALUE_PARAMETER name:b index:1 type:kotlin.Short flags: BLOCK_BODY RETURN type=kotlin.Nothing from='stest3(Short, Short): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Short): Int' type=kotlin.Int origin=GTEQ + CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Short' type=kotlin.Short origin=null - other: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null FUN name:stest4 visibility:public modality:FINAL <> (a:kotlin.Short, b:kotlin.Short) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Short flags: VALUE_PARAMETER name:b index:1 type:kotlin.Short flags: BLOCK_BODY RETURN type=kotlin.Nothing from='stest4(Short, Short): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Short): Int' type=kotlin.Int origin=LTEQ + CALL 'lessOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: CALL 'toInt(): Int' type=kotlin.Int origin=null $this: GET_VAR 'value-parameter a: Short' type=kotlin.Short origin=null - other: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null + arg1: CALL 'toInt(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'value-parameter b: Short' type=kotlin.Short origin=null FUN name:itest1 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Int flags: VALUE_PARAMETER name:b index:1 type:kotlin.Int flags: BLOCK_BODY RETURN type=kotlin.Nothing from='itest1(Int, Int): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null - other: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null + arg1: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null FUN name:itest2 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Int flags: VALUE_PARAMETER name:b index:1 type:kotlin.Int flags: BLOCK_BODY RETURN type=kotlin.Nothing from='itest2(Int, Int): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null - other: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null + arg1: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null FUN name:itest3 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Int flags: VALUE_PARAMETER name:b index:1 type:kotlin.Int flags: BLOCK_BODY RETURN type=kotlin.Nothing from='itest3(Int, Int): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GTEQ - $this: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null - other: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null + CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null + arg1: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null FUN name:itest4 visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Int flags: VALUE_PARAMETER name:b index:1 type:kotlin.Int flags: BLOCK_BODY RETURN type=kotlin.Nothing from='itest4(Int, Int): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LTEQ - $this: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null - other: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null + CALL 'lessOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: GET_VAR 'value-parameter a: Int' type=kotlin.Int origin=null + arg1: GET_VAR 'value-parameter b: Int' type=kotlin.Int origin=null FUN name:ltest1 visibility:public modality:FINAL <> (a:kotlin.Long, b:kotlin.Long) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Long flags: VALUE_PARAMETER name:b index:1 type:kotlin.Long flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ltest1(Long, Long): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Long): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null - other: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null + CALL 'greater(Long, Long): Boolean' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null + arg1: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null FUN name:ltest2 visibility:public modality:FINAL <> (a:kotlin.Long, b:kotlin.Long) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Long flags: VALUE_PARAMETER name:b index:1 type:kotlin.Long flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ltest2(Long, Long): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Long): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null - other: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null + CALL 'less(Long, Long): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null + arg1: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null FUN name:ltest3 visibility:public modality:FINAL <> (a:kotlin.Long, b:kotlin.Long) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Long flags: VALUE_PARAMETER name:b index:1 type:kotlin.Long flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ltest3(Long, Long): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Long): Int' type=kotlin.Int origin=GTEQ - $this: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null - other: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null + CALL 'greaterOrEqual(Long, Long): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null + arg1: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null FUN name:ltest4 visibility:public modality:FINAL <> (a:kotlin.Long, b:kotlin.Long) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Long flags: VALUE_PARAMETER name:b index:1 type:kotlin.Long flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ltest4(Long, Long): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Long): Int' type=kotlin.Int origin=LTEQ - $this: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null - other: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null + CALL 'lessOrEqual(Long, Long): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: GET_VAR 'value-parameter a: Long' type=kotlin.Long origin=null + arg1: GET_VAR 'value-parameter b: Long' type=kotlin.Long origin=null FUN name:ftest1 visibility:public modality:FINAL <> (a:kotlin.Float, b:kotlin.Float) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Float flags: VALUE_PARAMETER name:b index:1 type:kotlin.Float flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ftest1(Float, Float): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null - other: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null + CALL 'greater(Float, Float): Boolean' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null FUN name:ftest2 visibility:public modality:FINAL <> (a:kotlin.Float, b:kotlin.Float) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Float flags: VALUE_PARAMETER name:b index:1 type:kotlin.Float flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ftest2(Float, Float): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null - other: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null + CALL 'less(Float, Float): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null FUN name:ftest3 visibility:public modality:FINAL <> (a:kotlin.Float, b:kotlin.Float) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Float flags: VALUE_PARAMETER name:b index:1 type:kotlin.Float flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ftest3(Float, Float): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=GTEQ - $this: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null - other: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null + CALL 'greaterOrEqual(Float, Float): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null FUN name:ftest4 visibility:public modality:FINAL <> (a:kotlin.Float, b:kotlin.Float) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Float flags: VALUE_PARAMETER name:b index:1 type:kotlin.Float flags: BLOCK_BODY RETURN type=kotlin.Nothing from='ftest4(Float, Float): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Float): Int' type=kotlin.Int origin=LTEQ - $this: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null - other: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null + CALL 'lessOrEqual(Float, Float): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: GET_VAR 'value-parameter a: Float' type=kotlin.Float origin=null + arg1: GET_VAR 'value-parameter b: Float' type=kotlin.Float origin=null FUN name:dtest1 visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Double flags: VALUE_PARAMETER name:b index:1 type:kotlin.Double flags: BLOCK_BODY RETURN type=kotlin.Nothing from='dtest1(Double, Double): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null - other: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null + CALL 'greater(Double, Double): Boolean' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null FUN name:dtest2 visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Double flags: VALUE_PARAMETER name:b index:1 type:kotlin.Double flags: BLOCK_BODY RETURN type=kotlin.Nothing from='dtest2(Double, Double): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null - other: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null + CALL 'less(Double, Double): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null FUN name:dtest3 visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Double flags: VALUE_PARAMETER name:b index:1 type:kotlin.Double flags: BLOCK_BODY RETURN type=kotlin.Nothing from='dtest3(Double, Double): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ - arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=GTEQ - $this: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null - other: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null + CALL 'greaterOrEqual(Double, Double): Boolean' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null FUN name:dtest4 visibility:public modality:FINAL <> (a:kotlin.Double, b:kotlin.Double) returnType:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.Double flags: VALUE_PARAMETER name:b index:1 type:kotlin.Double flags: BLOCK_BODY RETURN type=kotlin.Nothing from='dtest4(Double, Double): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ - arg0: CALL 'compareTo(Double): Int' type=kotlin.Int origin=LTEQ - $this: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null - other: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null - + CALL 'lessOrEqual(Double, Double): Boolean' type=kotlin.Boolean origin=LTEQ + arg0: GET_VAR 'value-parameter a: Double' type=kotlin.Double origin=null + arg1: GET_VAR 'value-parameter b: Double' type=kotlin.Double origin=null diff --git a/compiler/testData/ir/irText/expressions/stringComparisons.txt b/compiler/testData/ir/irText/expressions/stringComparisons.txt index 990b298c02d..e44cb36c853 100644 --- a/compiler/testData/ir/irText/expressions/stringComparisons.txt +++ b/compiler/testData/ir/irText/expressions/stringComparisons.txt @@ -4,35 +4,38 @@ FILE fqName: fileName:/stringComparisons.kt VALUE_PARAMETER name:b index:1 type:kotlin.String flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test1(String, String): Boolean' - CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT arg0: CALL 'compareTo(String): Int' type=kotlin.Int origin=GT $this: GET_VAR 'value-parameter a: String' type=kotlin.String origin=null other: GET_VAR 'value-parameter b: String' 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:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.String flags: VALUE_PARAMETER name:b index:1 type:kotlin.String flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test2(String, String): Boolean' - CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT arg0: CALL 'compareTo(String): Int' type=kotlin.Int origin=LT $this: GET_VAR 'value-parameter a: String' type=kotlin.String origin=null other: GET_VAR 'value-parameter b: String' 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:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.String flags: VALUE_PARAMETER name:b index:1 type:kotlin.String flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test3(String, String): Boolean' - CALL 'GTEQ0(Int): Boolean' type=kotlin.Boolean origin=GTEQ + CALL 'greaterOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=GTEQ arg0: CALL 'compareTo(String): Int' type=kotlin.Int origin=GTEQ $this: GET_VAR 'value-parameter a: String' type=kotlin.String origin=null other: GET_VAR 'value-parameter b: String' 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:Boolean flags: VALUE_PARAMETER name:a index:0 type:kotlin.String flags: VALUE_PARAMETER name:b index:1 type:kotlin.String flags: BLOCK_BODY RETURN type=kotlin.Nothing from='test4(String, String): Boolean' - CALL 'LTEQ0(Int): Boolean' type=kotlin.Boolean origin=LTEQ + CALL 'lessOrEqual(Int, Int): Boolean' type=kotlin.Boolean origin=LTEQ arg0: CALL 'compareTo(String): Int' type=kotlin.Int origin=LTEQ $this: GET_VAR 'value-parameter a: String' type=kotlin.String origin=null other: GET_VAR 'value-parameter b: String' type=kotlin.String origin=null - + arg1: CONST Int type=kotlin.Int value=0 diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.txt index d2f1db1e5e7..d68e6b06679 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.txt @@ -4,15 +4,13 @@ FILE fqName: fileName:/whileDoWhile.kt VAR name:x type:kotlin.Int flags:var CONST Int type=kotlin.Int value=0 WHILE label=null origin=WHILE_LOOP - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=0 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 WHILE label=null origin=WHILE_LOOP - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=5 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=5 body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=POSTFIX_INCR VAR IR_TEMPORARY_VARIABLE name:tmp0 type:kotlin.Int flags:val @@ -22,10 +20,9 @@ FILE fqName: fileName:/whileDoWhile.kt $this: GET_VAR 'tmp0: Int' type=kotlin.Int origin=null GET_VAR 'tmp0: Int' type=kotlin.Int origin=null WHILE label=null origin=WHILE_LOOP - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=10 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 body: BLOCK type=kotlin.Unit origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=POSTFIX_INCR @@ -37,10 +34,9 @@ FILE fqName: fileName:/whileDoWhile.kt GET_VAR 'tmp1: Int' type=kotlin.Int origin=null BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=0 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit @@ -51,10 +47,9 @@ FILE fqName: fileName:/whileDoWhile.kt CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR $this: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null GET_VAR 'tmp2: Int' type=kotlin.Int origin=null - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=15 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=15 BLOCK type=kotlin.Unit origin=null DO_WHILE label=null origin=DO_WHILE_LOOP body: COMPOSITE type=kotlin.Unit origin=null @@ -66,10 +61,9 @@ FILE fqName: fileName:/whileDoWhile.kt CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR $this: GET_VAR 'tmp3: Int' type=kotlin.Int origin=null GET_VAR 'tmp3: Int' type=kotlin.Int origin=null - condition: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'x: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value=20 + condition: CALL 'less(Int, Int): Boolean' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'x: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=20 FUN name:testSmartcastInCondition visibility:public modality:FINAL <> () returnType:Unit flags: BLOCK_BODY VAR name:a type:kotlin.Any? flags:val @@ -88,4 +82,3 @@ FILE fqName: fileName:/whileDoWhile.kt body: COMPOSITE type=kotlin.Unit origin=null condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean GET_VAR 'a: Any?' type=kotlin.Any? origin=null - diff --git a/compiler/testData/ir/irText/regressions/coercionInLoop.txt b/compiler/testData/ir/irText/regressions/coercionInLoop.txt index 9a67999e556..6f6c0b4030e 100644 --- a/compiler/testData/ir/irText/regressions/coercionInLoop.txt +++ b/compiler/testData/ir/irText/regressions/coercionInLoop.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/coercionInLoop.kt WHEN type=kotlin.Unit origin=null BRANCH if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'ieee754equals(Double?, Double?): Boolean' type=kotlin.Boolean origin=EXCLEQ arg0: CALL 'get(Int): Double' type=kotlin.Double origin=GET_ARRAY_ELEMENT $this: GET_VAR 'a: DoubleArray' type=kotlin.DoubleArray origin=null index: GET_VAR 'i: Int' type=kotlin.Int origin=null @@ -36,4 +36,3 @@ FILE fqName: fileName:/coercionInLoop.kt GET_VAR 'tmp0: Int' type=kotlin.Int origin=null RETURN type=kotlin.Nothing from='box(): String' CONST String type=kotlin.String value=OK - diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 359273053b3..e99cc595f5f 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -995,6 +995,63 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/whileDoWhile.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FloatingPointComparisons extends AbstractIrTextTestCase { + public void testAllFilesPresentInFloatingPointComparisons() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/expressions/floatingPointComparisons"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("comparableWithDoubleOrFloat.kt") + public void testComparableWithDoubleOrFloat() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/comparableWithDoubleOrFloat.kt"); + doTest(fileName); + } + + @TestMetadata("floatingPointCompareTo.kt") + public void testFloatingPointCompareTo() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointCompareTo.kt"); + doTest(fileName); + } + + @TestMetadata("floatingPointEqeq.kt") + public void testFloatingPointEqeq() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEqeq.kt"); + doTest(fileName); + } + + @TestMetadata("floatingPointEquals.kt") + public void testFloatingPointEquals() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointEquals.kt"); + doTest(fileName); + } + + @TestMetadata("floatingPointExcleq.kt") + public void testFloatingPointExcleq() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointExcleq.kt"); + doTest(fileName); + } + + @TestMetadata("floatingPointLess.kt") + public void testFloatingPointLess() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/floatingPointLess.kt"); + doTest(fileName); + } + + @TestMetadata("nullableAnyAsIntToDouble.kt") + public void testNullableAnyAsIntToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableAnyAsIntToDouble.kt"); + doTest(fileName); + } + + @TestMetadata("nullableFloatingPointEqeq.kt") + public void testNullableFloatingPointEqeq() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/expressions/floatingPointComparisons/nullableFloatingPointEqeq.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/ir/irText/lambdas")