From 8eeb7e2631030129275a575e382922891afac43a Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Thu, 16 Mar 2023 11:22:53 +0100 Subject: [PATCH] Modify test data to reflect changes with `IntrinsicConstEvaluation` --- ...CompilerTestFE10TestdataTestGenerated.java | 48 ++++-- ...eeOldFrontendDiagnosticsTestGenerated.java | 48 ++++-- ...siOldFrontendDiagnosticsTestGenerated.java | 48 ++++-- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 + .../FirPsiBlackBoxCodegenTestGenerated.java | 6 + .../foldingBinaryOpsUnsignedConst.kt | 2 +- .../dumpIrAndCheck/booleanOperations.kt | 10 +- .../dumpIrAndCheck/byteOperations.kt | 10 +- .../dumpIrAndCheck/charOperations.kt | 10 +- .../dumpIrAndCheck/constTrimIndent.kt | 1 + .../dumpIrAndCheck/constTrimMargin.kt | 1 + .../dumpIrAndCheck/doubleOperations.kt | 10 +- .../dumpIrAndCheck/enumName.kt | 1 + .../dumpIrAndCheck/equals_after.kt | 141 ++++++++++++++++++ .../dumpIrAndCheck/floatOperations.kt | 10 +- .../dumpIrAndCheck/ifConstVal.kt | 1 + .../dumpIrAndCheck/intOperations.kt | 10 +- .../dumpIrAndCheck/kCallableName.kt | 1 + .../dumpIrAndCheck/kt53272.kt | 1 + .../dumpIrAndCheck/longOperations.kt | 10 +- .../dumpIrAndCheck/shortOperations.kt | 10 +- .../dumpIrAndCheck/stringOperations.kt | 10 +- .../tests/modifiers/const/enumConstName.txt | 32 ---- ...Name.fir.kt => enumConstName_after.fir.kt} | 4 +- ...numConstName.kt => enumConstName_after.kt} | 2 + .../modifiers/const/enumConstName_before.kt | 11 ++ .../tests/modifiers/const/equals_after.fir.kt | 46 ++++++ .../tests/modifiers/const/equals_after.kt | 46 ++++++ .../modifiers/const/equals_before.fir.kt | 46 ++++++ .../tests/modifiers/const/equals_before.kt | 46 ++++++ .../tests/modifiers/const/ifConstVal.txt | 13 -- ...onstVal.fir.kt => ifConstVal_after.fir.kt} | 2 + .../{ifConstVal.kt => ifConstVal_after.kt} | 2 + .../modifiers/const/ifConstVal_before.kt | 25 ++++ .../tests/modifiers/const/kCallable.txt | 22 --- ...Callable.fir.kt => kCallable_after.fir.kt} | 2 + .../{kCallable.kt => kCallable_after.kt} | 2 + .../tests/modifiers/const/kCallable_before.kt | 21 +++ .../test/runners/DiagnosticTestGenerated.java | 48 ++++-- .../IrBlackBoxCodegenTestGenerated.java | 6 + ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 + 41 files changed, 617 insertions(+), 160 deletions(-) create mode 100644 compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt delete mode 100644 compiler/testData/diagnostics/tests/modifiers/const/enumConstName.txt rename compiler/testData/diagnostics/tests/modifiers/const/{enumConstName.fir.kt => enumConstName_after.fir.kt} (68%) rename compiler/testData/diagnostics/tests/modifiers/const/{enumConstName.kt => enumConstName_after.kt} (90%) create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/equals_after.fir.kt create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/equals_before.fir.kt create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt delete mode 100644 compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.txt rename compiler/testData/diagnostics/tests/modifiers/const/{ifConstVal.fir.kt => ifConstVal_after.fir.kt} (93%) rename compiler/testData/diagnostics/tests/modifiers/const/{ifConstVal.kt => ifConstVal_after.kt} (95%) create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt delete mode 100644 compiler/testData/diagnostics/tests/modifiers/const/kCallable.txt rename compiler/testData/diagnostics/tests/modifiers/const/{kCallable.fir.kt => kCallable_after.fir.kt} (94%) rename compiler/testData/diagnostics/tests/modifiers/const/{kCallable.kt => kCallable_after.kt} (96%) create mode 100644 compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 3930d073194..8e619512253 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -21152,9 +21152,27 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } @Test - @TestMetadata("enumConstName.kt") - public void testEnumConstName() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt"); + @TestMetadata("enumConstName_after.kt") + public void testEnumConstName_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt"); + } + + @Test + @TestMetadata("enumConstName_before.kt") + public void testEnumConstName_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt"); + } + + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt"); + } + + @Test + @TestMetadata("equals_before.kt") + public void testEquals_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt"); } @Test @@ -21170,15 +21188,27 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } @Test - @TestMetadata("ifConstVal.kt") - public void testIfConstVal() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt"); + @TestMetadata("ifConstVal_after.kt") + public void testIfConstVal_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt"); } @Test - @TestMetadata("kCallable.kt") - public void testKCallable() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt"); + @TestMetadata("ifConstVal_before.kt") + public void testIfConstVal_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt"); + } + + @Test + @TestMetadata("kCallable_after.kt") + public void testKCallable_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt"); + } + + @Test + @TestMetadata("kCallable_before.kt") + public void testKCallable_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt"); } @Test diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index f6ba0456ed5..2210a777d96 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -21152,9 +21152,27 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir } @Test - @TestMetadata("enumConstName.kt") - public void testEnumConstName() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt"); + @TestMetadata("enumConstName_after.kt") + public void testEnumConstName_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt"); + } + + @Test + @TestMetadata("enumConstName_before.kt") + public void testEnumConstName_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt"); + } + + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt"); + } + + @Test + @TestMetadata("equals_before.kt") + public void testEquals_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt"); } @Test @@ -21170,15 +21188,27 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir } @Test - @TestMetadata("ifConstVal.kt") - public void testIfConstVal() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt"); + @TestMetadata("ifConstVal_after.kt") + public void testIfConstVal_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt"); } @Test - @TestMetadata("kCallable.kt") - public void testKCallable() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt"); + @TestMetadata("ifConstVal_before.kt") + public void testIfConstVal_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt"); + } + + @Test + @TestMetadata("kCallable_after.kt") + public void testKCallable_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt"); + } + + @Test + @TestMetadata("kCallable_before.kt") + public void testKCallable_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt"); } @Test diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index ef200242782..233b45c39eb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -21158,9 +21158,27 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia } @Test - @TestMetadata("enumConstName.kt") - public void testEnumConstName() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt"); + @TestMetadata("enumConstName_after.kt") + public void testEnumConstName_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt"); + } + + @Test + @TestMetadata("enumConstName_before.kt") + public void testEnumConstName_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt"); + } + + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt"); + } + + @Test + @TestMetadata("equals_before.kt") + public void testEquals_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt"); } @Test @@ -21176,15 +21194,27 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia } @Test - @TestMetadata("ifConstVal.kt") - public void testIfConstVal() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt"); + @TestMetadata("ifConstVal_after.kt") + public void testIfConstVal_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt"); } @Test - @TestMetadata("kCallable.kt") - public void testKCallable() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt"); + @TestMetadata("ifConstVal_before.kt") + public void testIfConstVal_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt"); + } + + @Test + @TestMetadata("kCallable_after.kt") + public void testKCallable_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt"); + } + + @Test + @TestMetadata("kCallable_before.kt") + public void testKCallable_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt"); } @Test diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 65221940182..6eb149fd517 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -28334,6 +28334,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumRecursiveName.kt"); } + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt"); + } + @Test @TestMetadata("floatOperations.kt") public void testFloatOperations() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 57f1f51e28d..1802b5fd83a 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -28334,6 +28334,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumRecursiveName.kt"); } + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt"); + } + @Test @TestMetadata("floatOperations.kt") public void testFloatOperations() throws Exception { diff --git a/compiler/testData/codegen/box/constants/foldingBinaryOpsUnsignedConst.kt b/compiler/testData/codegen/box/constants/foldingBinaryOpsUnsignedConst.kt index d590c0116af..73e3edac421 100644 --- a/compiler/testData/codegen/box/constants/foldingBinaryOpsUnsignedConst.kt +++ b/compiler/testData/codegen/box/constants/foldingBinaryOpsUnsignedConst.kt @@ -1,4 +1,4 @@ -// IGNORE_BACKEND_K2: JS_IR, NATIVE +// IGNORE_BACKEND_K2: NATIVE // WITH_STDLIB const val a = "INT " + 0x8fffffffU diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/booleanOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/booleanOperations.kt index 06ea8e77e3b..8d2a5586589 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/booleanOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/booleanOperations.kt @@ -26,11 +26,10 @@ const val compareTo2 = trueVal.compareTo(falseVal) const val compareTo3 = falseVal.compareTo(trueVal) const val compareTo4 = falseVal.compareTo(falseVal) -const val equals1 = trueVal.equals(trueVal) -const val equals2 = trueVal.equals(falseVal) -const val equals3 = falseVal.equals(trueVal) -const val equals4 = falseVal.equals(falseVal) -const val equals5 = falseVal.equals(1) +const val equals1 = trueVal == trueVal +const val equals2 = trueVal == falseVal +const val equals3 = falseVal == trueVal +const val equals4 = falseVal == falseVal const val toString1 = trueVal.toString() const val toString2 = falseVal.toString() @@ -63,7 +62,6 @@ fun box(): String { if (equals2 != false) return "Fail 6.2" if (equals3 != false) return "Fail 6.3" if (equals4 != true) return "Fail 6.4" - if (equals5 != false) return "Fail 6.5" if (toString1 != "true") return "Fail 7.1" if (toString2 != "false") return "Fail 7.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/byteOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/byteOperations.kt index 40540ccce0f..3cbbb11d586 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/byteOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/byteOperations.kt @@ -81,11 +81,10 @@ const val convert5 = oneVal.toLong() const val convert6 = oneVal.toFloat() const val convert7 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -162,7 +161,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1") return "Fail 10.1" if (toString2 != "2") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/charOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/charOperations.kt index 0d9530b0c85..71e9298cd3e 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/charOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/charOperations.kt @@ -36,11 +36,10 @@ const val convert5 = oneVal.toLong() const val convert6 = oneVal.toFloat() const val convert7 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals(1) +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -83,7 +82,6 @@ fun box(): String { if (equals2 != true) return "Fail 6.2" if (equals3 != false) return "Fail 6.3" if (equals4 != false) return "Fail 6.4" - if (equals5 != false) return "Fail 6.5" if (toString1 != "1") return "Fail 7.1" if (toString2 != "2") return "Fail 7.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimIndent.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimIndent.kt index 3ee1fa7c345..ec4adb5c0c7 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimIndent.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimIndent.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR // WITH_STDLIB diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimMargin.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimMargin.kt index 8f5d7fa307c..0e75fe9d59d 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimMargin.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/constTrimMargin.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR // WITH_STDLIB diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt index a703fb55400..a05e8955e36 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/doubleOperations.kt @@ -79,11 +79,10 @@ const val convert3 = oneVal.toLong() const val convert4 = oneVal.toFloat() const val convert5 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -158,7 +157,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1.0") return "Fail 10.1" if (toString2 != "2.0") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumName.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumName.kt index 162e67f5edc..7639792d0f0 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumName.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumName.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt new file mode 100644 index 00000000000..83b44722a2c --- /dev/null +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt @@ -0,0 +1,141 @@ +// !LANGUAGE: +IntrinsicConstEvaluation +// TARGET_BACKEND: JVM_IR + +const val trueVal = true +const val falseVal = false + +const val charOneVal = '1' +const val charTwoVal = '2' +const val charThreeVal = '3' +const val charFourVal = '4' + +const val byteMinusOneVal = (-1).toByte() +const val byteOneVal = 1.toByte() +const val byteTwoVal = 2.toByte() +const val byteThreeVal = 3.toByte() +const val byteFourVal = 4.toByte() + +const val shortMinusOneVal = (-1).toShort() +const val shortOneVal = 1.toShort() +const val shortTwoVal = 2.toShort() +const val shortThreeVal = 3.toShort() +const val shortFourVal = 4.toShort() + +const val intMinusOneVal = -1 +const val intOneVal = 1 +const val intTwoVal = 2 +const val intThreeVal = 3 +const val intFourVal = 4 + +const val longMinusOneVal = -1L +const val longOneVal = 1L +const val longTwoVal = 2L +const val longThreeVal = 3L +const val longFourVal = 4L + +const val floatMinusOneVal = -1.0f +const val floatOneVal = 1.0f +const val floatTwoVal = 2.0f +const val floatThreeVal = 3.0f +const val floatFourVal = 4.0f + +const val doubleMinusOneVal = -1.0 +const val doubleOneVal = 1.0 +const val doubleTwoVal = 2.0 +const val doubleThreeVal = 3.0 +const val doubleFourVal = 4.0 + +const val someStr = "123" +const val otherStr = "other" + +const val equalsBoolean1 = trueVal.equals(trueVal) +const val equalsBoolean2 = trueVal == falseVal +const val equalsBoolean3 = falseVal.equals(1) + +const val equalsChar1 = charOneVal.equals(charTwoVal) +const val equalsChar2 = charTwoVal.equals(charTwoVal) +const val equalsChar3 = charThreeVal == charTwoVal +const val equalsChar4 = charFourVal.equals(1) + +const val equalsByte1 = byteOneVal.equals(byteTwoVal) +const val equalsByte2 = byteTwoVal.equals(byteTwoVal) +const val equalsByte3 = byteThreeVal == byteTwoVal +const val equalsByte4 = byteFourVal.equals(1) + +const val equalsShort1 = shortOneVal.equals(shortTwoVal) +const val equalsShort2 = shortTwoVal.equals(shortTwoVal) +const val equalsShort3 = shortThreeVal == shortTwoVal +const val equalsShort4 = shortFourVal.equals(1) + +const val equalsInt1 = intOneVal.equals(intTwoVal) +const val equalsInt2 = intTwoVal.equals(intTwoVal) +const val equalsInt3 = intThreeVal == intTwoVal +const val equalsInt4 = intFourVal.equals(1) + +const val equalsLong1 = longOneVal.equals(longTwoVal) +const val equalsLong2 = longTwoVal.equals(longTwoVal) +const val equalsLong3 = longThreeVal == longTwoVal +const val equalsLong4 = longFourVal.equals(1) + +const val equalsFloat1 = floatOneVal.equals(floatTwoVal) +const val equalsFloat2 = floatTwoVal.equals(floatTwoVal) +const val equalsFloat3 = floatThreeVal == floatTwoVal +const val equalsFloat4 = floatFourVal.equals(1) + +const val equalsDouble1 = doubleOneVal.equals(doubleTwoVal) +const val equalsDouble2 = doubleTwoVal.equals(doubleTwoVal) +const val equalsDouble3 = doubleThreeVal == doubleTwoVal +const val equalsDouble4 = doubleFourVal.equals(1) + +const val equalsString1 = someStr.equals(otherStr) +const val equalsString2 = someStr.equals("123") +const val equalsString3 = otherStr == someStr +const val equalsString4 = someStr.equals(1) + +fun box(): String { + if (equalsBoolean1 != true) return "Fail 1.1" + if (equalsBoolean2 != false) return "Fail 1.2" + if (equalsBoolean3 != false) return "Fail 1.3" + + if (equalsChar1 != false) return "Fail 2.1" + if (equalsChar2 != true) return "Fail 2.2" + if (equalsChar3 != false) return "Fail 2.3" + if (equalsChar4 != false) return "Fail 2.3" + + if (equalsByte1 != false) return "Fail 3.1" + if (equalsByte2 != true) return "Fail 3.2" + if (equalsByte3 != false) return "Fail 3.3" + if (equalsByte4 != false) return "Fail 3.3" + + if (equalsShort1 != false) return "Fail 4.1" + if (equalsShort2 != true) return "Fail 4.2" + if (equalsShort3 != false) return "Fail 4.3" + if (equalsShort4 != false) return "Fail 4.3" + + if (equalsInt1 != false) return "Fail 5.1" + if (equalsInt2 != true) return "Fail 5.2" + if (equalsInt3 != false) return "Fail 5.3" + if (equalsInt4 != false) return "Fail 5.3" + + if (equalsLong1 != false) return "Fail 6.1" + if (equalsLong2 != true) return "Fail 6.2" + if (equalsLong3 != false) return "Fail 6.3" + if (equalsLong4 != false) return "Fail 6.3" + + if (equalsFloat1 != false) return "Fail 7.1" + if (equalsFloat2 != true) return "Fail 7.2" + if (equalsFloat3 != false) return "Fail 7.3" + if (equalsFloat4 != false) return "Fail 7.3" + + if (equalsDouble1 != false) return "Fail 8.1" + if (equalsDouble2 != true) return "Fail 8.2" + if (equalsDouble3 != false) return "Fail 8.3" + if (equalsDouble4 != false) return "Fail 8.3" + + if (equalsString1 != false) return "Fail 9.1" + if (equalsString2 != true) return "Fail 9.2" + if (equalsString3 != false) return "Fail 9.3" + if (equalsString4 != false) return "Fail 9.3" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt index fc11715a363..7a2c51b3779 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/floatOperations.kt @@ -79,11 +79,10 @@ const val convert3 = oneVal.toLong() const val convert4 = oneVal.toFloat() const val convert5 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -158,7 +157,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1.0") return "Fail 10.1" if (toString2 != "2.0") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/ifConstVal.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/ifConstVal.kt index 4aadf5ef4e3..6d499ddc406 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/ifConstVal.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/ifConstVal.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt index 4425223a7db..8ef60c13283 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/intOperations.kt @@ -81,11 +81,10 @@ const val convert5 = oneVal.toLong() const val convert6 = oneVal.toFloat() const val convert7 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -162,7 +161,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1") return "Fail 10.1" if (toString2 != "2") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kCallableName.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kCallableName.kt index 253bfd78ed4..fe56d499257 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kCallableName.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kCallableName.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kt53272.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kt53272.kt index 8b25912b429..9766feea24d 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kt53272.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/kt53272.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +IntrinsicConstEvaluation // TARGET_BACKEND: JVM_IR // IGNORE_BACKEND_K1: JVM_IR diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/longOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/longOperations.kt index 1d10a176f60..c9f4875e36e 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/longOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/longOperations.kt @@ -81,11 +81,10 @@ const val convert5 = oneVal.toLong() const val convert6 = oneVal.toFloat() const val convert7 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -162,7 +161,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1") return "Fail 10.1" if (toString2 != "2") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/shortOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/shortOperations.kt index fa77935c467..33c893dd854 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/shortOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/shortOperations.kt @@ -81,11 +81,10 @@ const val convert5 = oneVal.toLong() const val convert6 = oneVal.toFloat() const val convert7 = oneVal.toDouble() -const val equals1 = oneVal.equals(twoVal) -const val equals2 = twoVal.equals(twoVal) -const val equals3 = threeVal.equals(twoVal) -const val equals4 = fourVal.equals(twoVal) -const val equals5 = oneVal.equals("1") +const val equals1 = oneVal == twoVal +const val equals2 = twoVal == twoVal +const val equals3 = threeVal == twoVal +const val equals4 = fourVal == twoVal const val toString1 = oneVal.toString() const val toString2 = twoVal.toString() @@ -162,7 +161,6 @@ fun box(): String { if (equals2 != true) return "Fail 9.2" if (equals3 != false) return "Fail 9.3" if (equals4 != false) return "Fail 9.4" - if (equals5 != false) return "Fail 9.5" if (toString1 != "1") return "Fail 10.1" if (toString2 != "2") return "Fail 10.2" diff --git a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/stringOperations.kt b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/stringOperations.kt index 027060f9a60..3d089be304b 100644 --- a/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/stringOperations.kt +++ b/compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/stringOperations.kt @@ -18,11 +18,9 @@ const val compareTo1 = someStr.compareTo("123") const val compareTo2 = someStr.compareTo(otherStr) const val compareTo3 = otherStr.compareTo(someStr) -const val equals1 = someStr.equals("123") -const val equals2 = someStr.equals(otherStr) -const val equals3 = otherStr.equals(someStr) -const val equals4 = someStr.equals(oneVal) -const val equals5 = someStr.equals(1) +const val equals1 = someStr == "123" +const val equals2 = someStr == otherStr +const val equals3 = otherStr == someStr const val toString1 = someStr.toString() @@ -43,8 +41,6 @@ fun box(): String { if (equals1 != true) return "Fail 5.1" if (equals2 != false) return "Fail 5.2" if (equals3 != false) return "Fail 5.3" - if (equals4 != false) return "Fail 5.4" - if (equals5 != false) return "Fail 5.5" if (toString1 != "123") return "Fail 6.1" return "OK" diff --git a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.txt b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.txt deleted file mode 100644 index 88a559a93ee..00000000000 --- a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.txt +++ /dev/null @@ -1,32 +0,0 @@ -package - -public const val name1: kotlin.String -public const val name2: kotlin.String -public const val name3: kotlin.String -public const val name4: kotlin.String - -public final enum class EnumClass : kotlin.Enum { - enum entry OK - - enum entry VALUE - - enum entry anotherValue - - enum entry WITH_UNDERSCORE - - private constructor EnumClass() - @kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String - public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int - protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any - public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: EnumClass): kotlin.Int - public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit - public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! - public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - - // Static members - public final /*synthesized*/ val entries: kotlin.enums.EnumEntries - public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): EnumClass - public final /*synthesized*/ fun values(): kotlin.Array -} diff --git a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.fir.kt b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.fir.kt similarity index 68% rename from compiler/testData/diagnostics/tests/modifiers/const/enumConstName.fir.kt rename to compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.fir.kt index 142c5ab708d..f5502048e2c 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.fir.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + enum class EnumClass { OK, VALUE, anotherValue, WITH_UNDERSCORE } @@ -5,4 +7,4 @@ enum class EnumClass { const val name1 = EnumClass.OK.name const val name2 = EnumClass.VALUE.name const val name3 = EnumClass.anotherValue.name -const val name4 = EnumClass.WITH_UNDERSCORE.name \ No newline at end of file +const val name4 = EnumClass.WITH_UNDERSCORE.name diff --git a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt similarity index 90% rename from compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt rename to compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt index 645ac89b918..38f69554198 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + enum class EnumClass { OK, VALUE, anotherValue, WITH_UNDERSCORE } diff --git a/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt new file mode 100644 index 00000000000..5b1a3bddb7f --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt @@ -0,0 +1,11 @@ +// FIR_IDENTICAL +// !LANGUAGE: -IntrinsicConstEvaluation + +enum class EnumClass { + OK, VALUE, anotherValue, WITH_UNDERSCORE +} + +const val name1 = EnumClass.OK.name +const val name2 = EnumClass.VALUE.name +const val name3 = EnumClass.anotherValue.name +const val name4 = EnumClass.WITH_UNDERSCORE.name diff --git a/compiler/testData/diagnostics/tests/modifiers/const/equals_after.fir.kt b/compiler/testData/diagnostics/tests/modifiers/const/equals_after.fir.kt new file mode 100644 index 00000000000..b4ae0448970 --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/equals_after.fir.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + +const val equalsBoolean1 = true.equals(true) +const val equalsBoolean2 = false != true +const val equalsBoolean3 = false.equals(1) +const val equalsBoolean4 = false == 1 + +const val equalsChar1 = '1'.equals('2') +const val equalsChar2 = '2' == '2' +const val equalsChar3 = '1'.equals(1) +const val equalsChar4 = '1' == 1 + +const val equalsByte1 = 1.toByte().equals(2.toByte()) +const val equalsByte2 = 2.toByte() == 2.toByte() +const val equalsByte3 = 1.toByte().equals("1") +const val equalsByte4 = 1.toByte() == "1" + +const val equalsShort1 = 1.toShort().equals(2.toShort()) +const val equalsShort2 = 2.toShort() == 2.toShort() +const val equalsShort3 = 1.toShort().equals("1") +const val equalsShort4 = 1.toShort() == "1" + +const val equalsInt1 = 1.equals(2) +const val equalsInt2 = 2 == 2 +const val equalsInt3 = 1.equals("1") +const val equalsInt4 = 1 == "1" + +const val equalsLong1 = 1L.equals(2L) +const val equalsLong2 = 2L == 2L +const val equalsLong3 = 1L.equals("1") +const val equalsLong4 = 1L == "1" + +const val equalsFloat1 = 1.0f.equals(2.0f) +const val equalsFloat2 = 2.0f == 2.0f +const val equalsFloat3 = 1.0f.equals("1") +const val equalsFloat4 = 1.0f == "1" + +const val equalsDoable1 = 1.0.equals(2.0) +const val equalsDoable2 = 2.0 == 2.0 +const val equalsDoable3 = 1.0.equals("1") +const val equalsDoable4 = 1.0 == "1" + +const val equalsString1 = "someStr".equals("123") +const val equalsString2 = "someStr" == "otherStr" +const val equalsString3 = "someStr".equals(1) +const val equalsString4 = "someStr" == 1 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt b/compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt new file mode 100644 index 00000000000..45a6371cc49 --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + +const val equalsBoolean1 = true.equals(true) +const val equalsBoolean2 = false != true +const val equalsBoolean3 = false.equals(1) +const val equalsBoolean4 = false == 1 + +const val equalsChar1 = '1'.equals('2') +const val equalsChar2 = '2' == '2' +const val equalsChar3 = '1'.equals(1) +const val equalsChar4 = '1' == 1 + +const val equalsByte1 = 1.toByte().equals(2.toByte()) +const val equalsByte2 = 2.toByte() == 2.toByte() +const val equalsByte3 = 1.toByte().equals("1") +const val equalsByte4 = 1.toByte() == "1" + +const val equalsShort1 = 1.toShort().equals(2.toShort()) +const val equalsShort2 = 2.toShort() == 2.toShort() +const val equalsShort3 = 1.toShort().equals("1") +const val equalsShort4 = 1.toShort() == "1" + +const val equalsInt1 = 1.equals(2) +const val equalsInt2 = 2 == 2 +const val equalsInt3 = 1.equals("1") +const val equalsInt4 = 1 == "1" + +const val equalsLong1 = 1L.equals(2L) +const val equalsLong2 = 2L == 2L +const val equalsLong3 = 1L.equals("1") +const val equalsLong4 = 1L == "1" + +const val equalsFloat1 = 1.0f.equals(2.0f) +const val equalsFloat2 = 2.0f == 2.0f +const val equalsFloat3 = 1.0f.equals("1") +const val equalsFloat4 = 1.0f == "1" + +const val equalsDoable1 = 1.0.equals(2.0) +const val equalsDoable2 = 2.0 == 2.0 +const val equalsDoable3 = 1.0.equals("1") +const val equalsDoable4 = 1.0 == "1" + +const val equalsString1 = "someStr".equals("123") +const val equalsString2 = "someStr" == "otherStr" +const val equalsString3 = "someStr".equals(1) +const val equalsString4 = "someStr" == 1 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/equals_before.fir.kt b/compiler/testData/diagnostics/tests/modifiers/const/equals_before.fir.kt new file mode 100644 index 00000000000..2d43fc2ed93 --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/equals_before.fir.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: -IntrinsicConstEvaluation + +const val equalsBoolean1 = true.equals(true) +const val equalsBoolean2 = false != true +const val equalsBoolean3 = false.equals(1) +const val equalsBoolean4 = false == 1 + +const val equalsChar1 = '1'.equals('2') +const val equalsChar2 = '2' == '2' +const val equalsChar3 = '1'.equals(1) +const val equalsChar4 = '1' == 1 + +const val equalsByte1 = 1.toByte().equals(2.toByte()) +const val equalsByte2 = 2.toByte() == 2.toByte() +const val equalsByte3 = 1.toByte().equals("1") +const val equalsByte4 = 1.toByte() == "1" + +const val equalsShort1 = 1.toShort().equals(2.toShort()) +const val equalsShort2 = 2.toShort() == 2.toShort() +const val equalsShort3 = 1.toShort().equals("1") +const val equalsShort4 = 1.toShort() == "1" + +const val equalsInt1 = 1.equals(2) +const val equalsInt2 = 2 == 2 +const val equalsInt3 = 1.equals("1") +const val equalsInt4 = 1 == "1" + +const val equalsLong1 = 1L.equals(2L) +const val equalsLong2 = 2L == 2L +const val equalsLong3 = 1L.equals("1") +const val equalsLong4 = 1L == "1" + +const val equalsFloat1 = 1.0f.equals(2.0f) +const val equalsFloat2 = 2.0f == 2.0f +const val equalsFloat3 = 1.0f.equals("1") +const val equalsFloat4 = 1.0f == "1" + +const val equalsDoable1 = 1.0.equals(2.0) +const val equalsDoable2 = 2.0 == 2.0 +const val equalsDoable3 = 1.0.equals("1") +const val equalsDoable4 = 1.0 == "1" + +const val equalsString1 = "someStr".equals("123") +const val equalsString2 = "someStr" == "otherStr" +const val equalsString3 = "someStr".equals(1) +const val equalsString4 = "someStr" == 1 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt b/compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt new file mode 100644 index 00000000000..00bfdc2f401 --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: -IntrinsicConstEvaluation + +const val equalsBoolean1 = true.equals(true) +const val equalsBoolean2 = false != true +const val equalsBoolean3 = false.equals(1) +const val equalsBoolean4 = false == 1 + +const val equalsChar1 = '1'.equals('2') +const val equalsChar2 = '2' == '2' +const val equalsChar3 = '1'.equals(1) +const val equalsChar4 = '1' == 1 + +const val equalsByte1 = 1.toByte().equals(2.toByte()) +const val equalsByte2 = 2.toByte() == 2.toByte() +const val equalsByte3 = 1.toByte().equals("1") +const val equalsByte4 = 1.toByte() == "1" + +const val equalsShort1 = 1.toShort().equals(2.toShort()) +const val equalsShort2 = 2.toShort() == 2.toShort() +const val equalsShort3 = 1.toShort().equals("1") +const val equalsShort4 = 1.toShort() == "1" + +const val equalsInt1 = 1.equals(2) +const val equalsInt2 = 2 == 2 +const val equalsInt3 = 1.equals("1") +const val equalsInt4 = 1 == "1" + +const val equalsLong1 = 1L.equals(2L) +const val equalsLong2 = 2L == 2L +const val equalsLong3 = 1L.equals("1") +const val equalsLong4 = 1L == "1" + +const val equalsFloat1 = 1.0f.equals(2.0f) +const val equalsFloat2 = 2.0f == 2.0f +const val equalsFloat3 = 1.0f.equals("1") +const val equalsFloat4 = 1.0f == "1" + +const val equalsDoable1 = 1.0.equals(2.0) +const val equalsDoable2 = 2.0 == 2.0 +const val equalsDoable3 = 1.0.equals("1") +const val equalsDoable4 = 1.0 == "1" + +const val equalsString1 = "someStr".equals("123") +const val equalsString2 = "someStr" == "otherStr" +const val equalsString3 = "someStr".equals(1) +const val equalsString4 = "someStr" == 1 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.txt b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.txt deleted file mode 100644 index 6889f80d22b..00000000000 --- a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -public const val condition: kotlin.String -public const val errorBranch: kotlin.Boolean -public const val errorConstIf: kotlin.Int -public const val flag: kotlin.Boolean = true -public const val multibranchIf: kotlin.Int -public val nonConstFlag: kotlin.Boolean = true -public const val value: kotlin.Int = 10 -public const val withWhen: kotlin.String -public const val withWhen2: kotlin.String -public const val withWhen3: kotlin.String - diff --git a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.fir.kt b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.fir.kt similarity index 93% rename from compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.fir.kt rename to compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.fir.kt index 51410485584..af6049a21a9 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.fir.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + const val flag = true const val value = 10 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt similarity index 95% rename from compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt rename to compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt index 63c8b77fa97..6fefbac3985 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + const val flag = true const val value = 10 diff --git a/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt new file mode 100644 index 00000000000..fd5910245bf --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt @@ -0,0 +1,25 @@ +// FIR_IDENTICAL +// !LANGUAGE: -IntrinsicConstEvaluation + +const val flag = true +const val value = 10 + +const val condition = if (flag) "True" else "Error" +const val withWhen = when (flag) { + true -> "True" + else -> "Error" +} +const val withWhen2 = when { + flag == true -> "True" + else -> "Error" +} +const val withWhen3 = when(value) { + 10 -> "1" + 100 -> "2" + else -> "3" +} +const val multibranchIf = if (value == 100) 1 else if (value == 1000) 2 else 3 + +val nonConstFlag = true +const val errorConstIf = if (nonConstFlag) 1 else 2 +const val errorBranch = if (flag) nonConstFlag else false diff --git a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.txt b/compiler/testData/diagnostics/tests/modifiers/const/kCallable.txt deleted file mode 100644 index c68680fa3ab..00000000000 --- a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.txt +++ /dev/null @@ -1,22 +0,0 @@ -package - -public const val anotherPropName: kotlin.String -public const val barName: kotlin.String -public const val className: kotlin.String -public const val errorAccess: kotlin.String -public const val errorPlus: kotlin.String -public const val fooName: kotlin.String -public const val lengthPropName: kotlin.String -public const val propName: kotlin.String -public const val stringClassName: kotlin.String - -public final class SomeClassWithName { - public constructor SomeClassWithName(/*0*/ property: kotlin.Int) - public final val anotherProperty: kotlin.String = "" - public final val property: kotlin.Int - public final fun bar(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Double): kotlin.String - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public final fun foo(): kotlin.Unit - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.fir.kt b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.fir.kt similarity index 94% rename from compiler/testData/diagnostics/tests/modifiers/const/kCallable.fir.kt rename to compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.fir.kt index 5df431db665..7d51e37ad87 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.fir.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.fir.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + class SomeClassWithName(val property: Int) { val anotherProperty: String = "" diff --git a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt similarity index 96% rename from compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt rename to compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt index b345f715d87..98458110f6d 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: +IntrinsicConstEvaluation + class SomeClassWithName(val property: Int) { val anotherProperty: String = "" diff --git a/compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt new file mode 100644 index 00000000000..4ebbdbf1075 --- /dev/null +++ b/compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt @@ -0,0 +1,21 @@ +// FIR_IDENTICAL +// !LANGUAGE: -IntrinsicConstEvaluation + +class SomeClassWithName(val property: Int) { + val anotherProperty: String = "" + + fun foo() {} + fun bar(a: Int, b: Double): String = "" +} + +const val className = ::SomeClassWithName.name +const val propName = SomeClassWithName::property.name +const val anotherPropName = SomeClassWithName::anotherProperty.name +const val fooName = SomeClassWithName::foo.name +const val barName = SomeClassWithName::bar.name + +const val stringClassName = ::String.name +const val lengthPropName = String::length.name + +const val errorAccess = SomeClassWithName(1)::property.name +const val errorPlus = "" + SomeClassWithName(1)::property diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 5b9decba296..6e3602b8ec8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -21158,9 +21158,27 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } @Test - @TestMetadata("enumConstName.kt") - public void testEnumConstName() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName.kt"); + @TestMetadata("enumConstName_after.kt") + public void testEnumConstName_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_after.kt"); + } + + @Test + @TestMetadata("enumConstName_before.kt") + public void testEnumConstName_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/enumConstName_before.kt"); + } + + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_after.kt"); + } + + @Test + @TestMetadata("equals_before.kt") + public void testEquals_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/equals_before.kt"); } @Test @@ -21176,15 +21194,27 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } @Test - @TestMetadata("ifConstVal.kt") - public void testIfConstVal() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal.kt"); + @TestMetadata("ifConstVal_after.kt") + public void testIfConstVal_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_after.kt"); } @Test - @TestMetadata("kCallable.kt") - public void testKCallable() throws Exception { - runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable.kt"); + @TestMetadata("ifConstVal_before.kt") + public void testIfConstVal_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/ifConstVal_before.kt"); + } + + @Test + @TestMetadata("kCallable_after.kt") + public void testKCallable_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_after.kt"); + } + + @Test + @TestMetadata("kCallable_before.kt") + public void testKCallable_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/modifiers/const/kCallable_before.kt"); } @Test diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index c9b9fe495e7..a9782405bdc 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -28334,6 +28334,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumRecursiveName.kt"); } + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt"); + } + @Test @TestMetadata("floatOperations.kt") public void testFloatOperations() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index c5f3417fbb4..11d991f1b74 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -28334,6 +28334,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/enumRecursiveName.kt"); } + @Test + @TestMetadata("equals_after.kt") + public void testEquals_after() throws Exception { + runTest("compiler/testData/codegen/box/involvesIrInterpreter/dumpIrAndCheck/equals_after.kt"); + } + @Test @TestMetadata("floatOperations.kt") public void testFloatOperations() throws Exception {