From 839ebba157baf65935e8ce90927420b328c4ced4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 9 Feb 2018 16:21:46 +0300 Subject: [PATCH] ProperNumberComparisons is disabled by default (until LDC decision) --- .../kotlin/codegen/ExpressionCodegen.java | 14 ++-- .../arguments/K2JVMCompilerArguments.kt | 6 ++ .../jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 4 + compiler/testData/cli/jvm/extraHelp.out | 1 + .../box/ieee754/asComparableToDouble.kt | 13 ++++ ...omparableToDouble_properIeeeComparisons.kt | 14 ++++ ...mparableToTWithT_properIeeeComparisons.kt} | 2 +- ...terCheckInBranch_properIeeeComparisons.kt} | 6 +- ...astToDifferentTypesWithNumericPromotion.kt | 75 +++++++++++++++++++ ...NumericPromotion_properIeeeComparisons.kt} | 2 +- ...ToDifferentTypes_properIeeeComparisons.kt} | 2 +- .../smartCastToDoubleAndComparableToDouble.kt | 13 ++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 48 +++++++++--- .../codegen/BlackBoxCodegenTestGenerated.java | 48 +++++++++--- .../LightAnalysisModeTestGenerated.java | 48 +++++++++--- .../kotlin/config/LanguageVersionSettings.kt | 2 +- .../semantics/JsCodegenBoxTestGenerated.java | 72 ++++++++++++++---- 17 files changed, 305 insertions(+), 65 deletions(-) create mode 100644 compiler/testData/codegen/box/ieee754/asComparableToDouble.kt create mode 100644 compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt rename compiler/testData/codegen/box/ieee754/{comparableToTWithTLV13.kt => comparableToTWithT_properIeeeComparisons.kt} (86%) rename compiler/testData/codegen/box/ieee754/{smartCastOnWhenSubjectAfterCheckInBranchLV13.kt => smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt} (79%) create mode 100644 compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt rename compiler/testData/codegen/box/ieee754/{smartCastToDifferentTypesWithNumericPromotionLV13.kt => smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt} (98%) rename compiler/testData/codegen/box/ieee754/{smartCastToDifferentTypesLV13.kt => smartCastToDifferentTypes_properIeeeComparisons.kt} (89%) create mode 100644 compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index 75a5751d17f..1f1179d4a42 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -3239,7 +3239,7 @@ public class ExpressionCodegen extends KtVisitor impleme rightType = right754Type.type; } } - else if (shouldUseProperNumberComparisons()) { + else if (shouldUseProperIeee754Comparisons()) { Type comparisonType = comparisonOperandType(left754Type.type, right754Type.type); if (comparisonType == Type.FLOAT_TYPE || comparisonType == Type.DOUBLE_TYPE) { return Ieee754Equality.create( @@ -3453,14 +3453,14 @@ public class ExpressionCodegen extends KtVisitor impleme TypeAndNullability right754Type = calcTypeForIeee754ArithmeticIfNeeded(right, getRightOperandType(primitiveNumericComparisonInfo)); Callable callable = resolveToCallable((FunctionDescriptor) resolvedCall.getResultingDescriptor(), false, resolvedCall); boolean isSame754ArithmeticTypes = left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type); - boolean properNumberComparisons = shouldUseProperNumberComparisons(); + boolean properIeee754Comparisons = shouldUseProperIeee754Comparisons(); - if (properNumberComparisons && left754Type != null && right754Type != null) { + if (properIeee754Comparisons && left754Type != null && right754Type != null) { type = comparisonOperandType(leftType, rightType); leftValue = gen(left); rightValue = gen(right); } - else if (!properNumberComparisons && + else if (!properIeee754Comparisons && callable instanceof IntrinsicCallable && ((isPrimitive(leftType) && isPrimitive(rightType)) || isSame754ArithmeticTypes)) { type = isSame754ArithmeticTypes ? left754Type.type : comparisonOperandType(leftType, rightType); leftValue = gen(left); @@ -3482,7 +3482,7 @@ public class ExpressionCodegen extends KtVisitor impleme if (expression == null) { return null; } - else if (shouldUseProperNumberComparisons()) { + else if (shouldUseProperIeee754Comparisons()) { return Ieee754Kt.calcProperTypeForIeee754ArithmeticIfNeeded(expression, bindingContext, inferredPrimitiveType, typeMapper); } else { @@ -3491,8 +3491,8 @@ public class ExpressionCodegen extends KtVisitor impleme } } - private boolean shouldUseProperNumberComparisons() { - return state.getLanguageVersionSettings().supportsFeature(LanguageFeature.ProperNumberComparisons); + private boolean shouldUseProperIeee754Comparisons() { + return state.getLanguageVersionSettings().supportsFeature(LanguageFeature.ProperIeee754Comparisons); } private StackValue generateAssignmentExpression(KtBinaryExpression expression) { diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index c6275a1953d..b4cffdaddd8 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -224,6 +224,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { ) var noExceptionOnExplicitEqualsForBoxedNull by FreezableVar(false) + @Argument( + value = "-Xproper-ieee754-comparisons", + description = "Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types" + ) + var properIeee754Comparisons by FreezableVar(false) + // Paths to output directories for friend modules. var friendPaths: Array? by FreezableVar(null) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 32c33540b0d..19cbb66f9a0 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -235,6 +235,10 @@ class K2JVMCompiler : CLICompiler() { extraLanguageFeatures[LanguageFeature.StrictJavaNullabilityAssertions] = LanguageFeature.State.ENABLED } + if (commandLineArguments.properIeee754Comparisons) { + extraLanguageFeatures[LanguageFeature.ProperIeee754Comparisons] = LanguageFeature.State.ENABLED + } + super.setupPlatformSpecificLanguageFeatureSettings(extraLanguageFeatures, commandLineArguments) } diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index fca911a48b2..664bd81fb4f 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -28,6 +28,7 @@ where advanced options include: -Xno-optimize Disable optimizations -Xno-param-assertions Don't generate not-null assertions on parameters of methods accessible from Java -Xno-receiver-assertions Don't generate not-null assertion for extension receiver arguments of platform types + -Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types -Xreport-perf Report detailed performance statistics -Xscript-resolver-environment= Script resolver environment in key-value pairs (the value could be quoted and escaped) diff --git a/compiler/testData/codegen/box/ieee754/asComparableToDouble.kt b/compiler/testData/codegen/box/ieee754/asComparableToDouble.kt new file mode 100644 index 00000000000..9ae66414371 --- /dev/null +++ b/compiler/testData/codegen/box/ieee754/asComparableToDouble.kt @@ -0,0 +1,13 @@ +// IGNORE_BACKEND: JS + +val minus: Any = -0.0 + +fun box(): String { + if (minus is Double) { + if ((minus as Comparable) >= 0.0) return "fail 0" + if ((minus as Comparable) == 0.0) return "fail 1" + if (minus == (0.0 as Comparable)) return "fail 2" + if (minus == (0.0F as Comparable)) return "fail 3" + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt b/compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt new file mode 100644 index 00000000000..b0f1c933dbc --- /dev/null +++ b/compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt @@ -0,0 +1,14 @@ +// !LANGUAGE: +ProperIeee754Comparisons +// IGNORE_BACKEND: JS + +val minus: Any = -0.0 + +fun box(): String { + if (minus is Double) { + if ((minus as Comparable) >= 0.0) return "fail 0" + if ((minus as Comparable) == 0.0) return "fail 1" + if (minus == (0.0 as Comparable)) return "fail 2" + if (minus == (0.0F as Comparable)) return "fail 3" + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt b/compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt similarity index 86% rename from compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt rename to compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt index 452be1dec63..6e2e9f77d2e 100644 --- a/compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt +++ b/compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +ProperIeee754Comparisons fun less(x: Comparable, y: Float) = x is Float && x < y fun less(x: Comparable, y: Double) = x is Double && x < y diff --git a/compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt b/compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt similarity index 79% rename from compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt rename to compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt index 3d8ef73e615..6dd5deb6964 100644 --- a/compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt +++ b/compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +ProperIeee754Comparisons fun testF(x: Any) = when (x) { @@ -15,10 +15,10 @@ fun testD(x: Any) = } fun box(): String { - val tf = testF(0.0F) + val tf = testF(-0.0F) if (tf != "0.0") return "Fail 1: $tf" - val td = testD(0.0) + val td = testD(-0.0) if (td != "0.0") return "Fail 2: $td" return "OK" diff --git a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt new file mode 100644 index 00000000000..e28e840f43f --- /dev/null +++ b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt @@ -0,0 +1,75 @@ +// IGNORE_BACKEND: JS + +fun eqDI(x: Any?, y: Any?) = x is Double? && y is Int? && x == y +fun eqDL(x: Any?, y: Any?) = x is Double? && y is Long? && x == y +fun eqID(x: Any?, y: Any?) = x is Int? && y is Double? && x == y +fun eqLD(x: Any?, y: Any?) = x is Long? && y is Double? && x == y +fun eqFI(x: Any?, y: Any?) = x is Float? && y is Int? && x == y +fun eqFL(x: Any?, y: Any?) = x is Float? && y is Long? && x == y +fun eqIF(x: Any?, y: Any?) = x is Int? && y is Float? && x == y +fun eqLF(x: Any?, y: Any?) = x is Long? && y is Float? && x == y + +fun testNullNull() { + if (!eqDI(null, null)) throw Exception() + if (!eqDL(null, null)) throw Exception() + if (!eqID(null, null)) throw Exception() + if (!eqLD(null, null)) throw Exception() + if (!eqFI(null, null)) throw Exception() + if (!eqFL(null, null)) throw Exception() + if (!eqIF(null, null)) throw Exception() + if (!eqLF(null, null)) throw Exception() +} + +fun testNull0() { + if (eqDI(null, 0)) throw Exception() + if (eqDL(null, 0L)) throw Exception() + if (eqID(null, 0.0)) throw Exception() + if (eqLD(null, 0.0)) throw Exception() + if (eqFI(null, 0)) throw Exception() + if (eqFL(null, 0L)) throw Exception() + if (eqIF(null, 0.0F)) throw Exception() + if (eqLF(null, 0.0F)) throw Exception() +} + +fun test0Null() { + if (eqDI(0.0, null)) throw Exception() + if (eqDL(0.0, null)) throw Exception() + if (eqID(0, null)) throw Exception() + if (eqLD(0L, null)) throw Exception() + if (eqFI(0.0F, null)) throw Exception() + if (eqFL(0.0F, null)) throw Exception() + if (eqIF(0, null)) throw Exception() + if (eqLF(0L, null)) throw Exception() +} + +fun testPlusMinus0() { + if (eqDI(-0.0, 0)) throw Exception() + if (eqDL(-0.0, 0L)) throw Exception() + if (eqID(0, -0.0)) throw Exception() + if (eqLD(0L, -0.0)) throw Exception() + if (eqFI(-0.0F, 0)) throw Exception() + if (eqFL(-0.0F, 0L)) throw Exception() + if (eqIF(0, -0.0F)) throw Exception() + if (eqLF(0L, -0.0F)) throw Exception() +} + +fun test01() { + if (eqDI(0.0, 1)) throw Exception() + if (eqDL(0.0, 1L)) throw Exception() + if (eqID(0, 1.0)) throw Exception() + if (eqLD(0L, 1.0)) throw Exception() + if (eqFI(0.0F, 1)) throw Exception() + if (eqFL(0.0F, 1L)) throw Exception() + if (eqIF(0, 1.0F)) throw Exception() + if (eqLF(0L, 1.0F)) throw Exception() +} + +fun box(): String { + testNullNull() + testNull0() + test0Null() + testPlusMinus0() + test01() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt similarity index 98% rename from compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt rename to compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt index dd6918036e5..fb469e43383 100644 --- a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt +++ b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +ProperIeee754Comparisons // IGNORE_BACKEND: JS fun eqDI(x: Any?, y: Any?) = x is Double? && y is Int? && x == y diff --git a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt similarity index 89% rename from compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt rename to compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt index 99ddfce8751..582053bdf55 100644 --- a/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt +++ b/compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt @@ -1,4 +1,4 @@ -// LANGUAGE_VERSION: 1.3 +// !LANGUAGE: +ProperIeee754Comparisons fun ne(x: Any, y: Any) = x is Double && y is Float && x != y fun lt(x: Any, y: Any) = x is Double && y is Float && x < y diff --git a/compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt b/compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt new file mode 100644 index 00000000000..f6ad5a161d2 --- /dev/null +++ b/compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +ProperIeee754Comparisons + +val minus: Any = -0.0 + +fun box(): String { + if (minus is Comparable<*> && minus is Double) { + if (minus < 0.0) return "fail 0" + if ((minus) != 0.0) return "fail 1" + if (minus != 0.0) return "fail 2" + if (minus != 0.0F) return "fail 3" + } + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 9c245380e9b..13a035f0b26 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -9993,9 +9993,21 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } - @TestMetadata("comparableToTWithTLV13.kt") - public void testComparableToTWithTLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt"); + @TestMetadata("asComparableToDouble.kt") + public void testAsComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble.kt"); + doTest(fileName); + } + + @TestMetadata("asComparableToDouble_properIeeeComparisons.kt") + public void testAsComparableToDouble_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("comparableToTWithT_properIeeeComparisons.kt") + public void testComparableToTWithT_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt"); doTest(fileName); } @@ -10161,9 +10173,9 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } - @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranchLV13.kt") - public void testSmartCastOnWhenSubjectAfterCheckInBranchLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt"); + @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt") + public void testSmartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt"); doTest(fileName); } @@ -10173,15 +10185,27 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesLV13.kt") - public void testSmartCastToDifferentTypesLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt"); doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesWithNumericPromotionLV13.kt") - public void testSmartCastToDifferentTypesWithNumericPromotionLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDifferentTypes_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypes_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDoubleAndComparableToDouble.kt") + public void testSmartCastToDoubleAndComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); doTest(fileName); } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 4efaa8cedd8..353e6c701ce 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -9993,9 +9993,21 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("comparableToTWithTLV13.kt") - public void testComparableToTWithTLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt"); + @TestMetadata("asComparableToDouble.kt") + public void testAsComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble.kt"); + doTest(fileName); + } + + @TestMetadata("asComparableToDouble_properIeeeComparisons.kt") + public void testAsComparableToDouble_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("comparableToTWithT_properIeeeComparisons.kt") + public void testComparableToTWithT_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt"); doTest(fileName); } @@ -10161,9 +10173,9 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranchLV13.kt") - public void testSmartCastOnWhenSubjectAfterCheckInBranchLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt"); + @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt") + public void testSmartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt"); doTest(fileName); } @@ -10173,15 +10185,27 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesLV13.kt") - public void testSmartCastToDifferentTypesLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt"); doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesWithNumericPromotionLV13.kt") - public void testSmartCastToDifferentTypesWithNumericPromotionLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDifferentTypes_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypes_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDoubleAndComparableToDouble.kt") + public void testSmartCastToDoubleAndComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); doTest(fileName); } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 65bad5e2090..c41ef4bc80b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -9993,9 +9993,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } - @TestMetadata("comparableToTWithTLV13.kt") - public void testComparableToTWithTLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt"); + @TestMetadata("asComparableToDouble.kt") + public void testAsComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble.kt"); + doTest(fileName); + } + + @TestMetadata("asComparableToDouble_properIeeeComparisons.kt") + public void testAsComparableToDouble_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("comparableToTWithT_properIeeeComparisons.kt") + public void testComparableToTWithT_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt"); doTest(fileName); } @@ -10161,9 +10173,9 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } - @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranchLV13.kt") - public void testSmartCastOnWhenSubjectAfterCheckInBranchLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt"); + @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt") + public void testSmartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt"); doTest(fileName); } @@ -10173,15 +10185,27 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesLV13.kt") - public void testSmartCastToDifferentTypesLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt"); doTest(fileName); } - @TestMetadata("smartCastToDifferentTypesWithNumericPromotionLV13.kt") - public void testSmartCastToDifferentTypesWithNumericPromotionLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDifferentTypes_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypes_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDoubleAndComparableToDouble.kt") + public void testSmartCastToDoubleAndComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); doTest(fileName); } diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 03056a3e3a3..401e1b1bb97 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -66,9 +66,9 @@ enum class LanguageFeature( NestedClassesInAnnotations(KOTLIN_1_3), JvmStaticInInterface(KOTLIN_1_3), InlineClasses(KOTLIN_1_3), - ProperNumberComparisons(KOTLIN_1_3), StrictJavaNullabilityAssertions(sinceVersion = null, defaultState = State.DISABLED), + ProperIeee754Comparisons(sinceVersion = null, defaultState = State.DISABLED), ReadDeserializedContracts(KOTLIN_1_3), UseReturnsEffect(KOTLIN_1_3), diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 26d95ce8b0f..7c5a3735781 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10917,9 +10917,33 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { doTest(fileName); } - @TestMetadata("comparableToTWithTLV13.kt") - public void testComparableToTWithTLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithTLV13.kt"); + @TestMetadata("asComparableToDouble.kt") + public void testAsComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("asComparableToDouble_properIeeeComparisons.kt") + public void testAsComparableToDouble_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/asComparableToDouble_properIeeeComparisons.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("comparableToTWithT_properIeeeComparisons.kt") + public void testComparableToTWithT_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/comparableToTWithT_properIeeeComparisons.kt"); doTest(fileName); } @@ -11115,9 +11139,9 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } - @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranchLV13.kt") - public void testSmartCastOnWhenSubjectAfterCheckInBranchLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranchLV13.kt"); + @TestMetadata("smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt") + public void testSmartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt"); doTest(fileName); } @@ -11133,15 +11157,9 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } - @TestMetadata("smartCastToDifferentTypesLV13.kt") - public void testSmartCastToDifferentTypesLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesLV13.kt"); - doTest(fileName); - } - - @TestMetadata("smartCastToDifferentTypesWithNumericPromotionLV13.kt") - public void testSmartCastToDifferentTypesWithNumericPromotionLV13() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotionLV13.kt"); + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion.kt"); try { doTest(fileName); } @@ -11151,6 +11169,30 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypesWithNumericPromotion_properIeeeComparisons.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("smartCastToDifferentTypes_properIeeeComparisons.kt") + public void testSmartCastToDifferentTypes_properIeeeComparisons() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDifferentTypes_properIeeeComparisons.kt"); + doTest(fileName); + } + + @TestMetadata("smartCastToDoubleAndComparableToDouble.kt") + public void testSmartCastToDoubleAndComparableToDouble() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/smartCastToDoubleAndComparableToDouble.kt"); + doTest(fileName); + } + @TestMetadata("when.kt") public void testWhen() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ieee754/when.kt");