From a86279b766393a09e89b45e78ccf275047243333 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 3 May 2023 17:04:23 +0200 Subject: [PATCH] IR text: add a test with data object --- .../FirLightTreeJvmIrTextTestGenerated.java | 6 +++ .../ir/FirPsiJvmIrTextTestGenerated.java | 6 +++ .../irText/firProblems/dataObject.fir.ir.txt | 45 +++++++++++++++++++ .../irText/firProblems/dataObject.fir.kt.txt | 28 ++++++++++++ .../ir/irText/firProblems/dataObject.ir.txt | 45 +++++++++++++++++++ .../ir/irText/firProblems/dataObject.kt | 3 ++ .../ir/irText/firProblems/dataObject.kt.txt | 27 +++++++++++ .../ir/ClassicJvmIrTextTestGenerated.java | 6 +++ .../klib/KlibIrTextTestCaseGenerated.java | 5 +++ .../FirLightTreeJsIrTextTestGenerated.java | 6 +++ .../test/fir/FirPsiJsIrTextTestGenerated.java | 6 +++ .../test/ir/ClassicJsIrTextTestGenerated.java | 6 +++ 12 files changed, 189 insertions(+) create mode 100644 compiler/testData/ir/irText/firProblems/dataObject.fir.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/dataObject.fir.kt.txt create mode 100644 compiler/testData/ir/irText/firProblems/dataObject.ir.txt create mode 100644 compiler/testData/ir/irText/firProblems/dataObject.kt create mode 100644 compiler/testData/ir/irText/firProblems/dataObject.kt.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index f15f9a6c0c1..7ef1d1fdabf 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -2618,6 +2618,12 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index 6bd0c69784f..de0f7d5d3fe 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -2618,6 +2618,12 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { diff --git a/compiler/testData/ir/irText/firProblems/dataObject.fir.ir.txt b/compiler/testData/ir/irText/firProblems/dataObject.fir.ir.txt new file mode 100644 index 00000000000..dfb8e9f9ac7 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/dataObject.fir.ir.txt @@ -0,0 +1,45 @@ +FILE fqName: fileName:/dataObject.kt + CLASS OBJECT name:DataObject modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DataObject + CONSTRUCTOR visibility:private <> () returnType:.DataObject [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:DataObject modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.DataObject, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.DataObject + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .DataObject declared in .DataObject.equals' type=.DataObject origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.DataObject + GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.DataObject [val] + TYPE_OP type=.DataObject origin=CAST typeOperand=.DataObject + GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.DataObject) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.DataObject + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .DataObject' + CONST Int type=kotlin.Int value=-1155894359 + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.DataObject) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.DataObject + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .DataObject' + CONST String type=kotlin.String value="DataObject" diff --git a/compiler/testData/ir/irText/firProblems/dataObject.fir.kt.txt b/compiler/testData/ir/irText/firProblems/dataObject.fir.kt.txt new file mode 100644 index 00000000000..6510ed17a67 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/dataObject.fir.kt.txt @@ -0,0 +1,28 @@ +data object DataObject { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is DataObject -> return false + } + val tmp0_other_with_cast: DataObject = other as DataObject + return true + } + + override fun hashCode(): Int { + return -1155894359 + } + + override fun toString(): String { + return "DataObject" + } + +} + diff --git a/compiler/testData/ir/irText/firProblems/dataObject.ir.txt b/compiler/testData/ir/irText/firProblems/dataObject.ir.txt new file mode 100644 index 00000000000..7367c2c28c0 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/dataObject.ir.txt @@ -0,0 +1,45 @@ +FILE fqName: fileName:/dataObject.kt + CLASS OBJECT name:DataObject modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.DataObject + CONSTRUCTOR visibility:private <> () returnType:.DataObject [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:DataObject modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.DataObject) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.DataObject + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .DataObject' + CONST String type=kotlin.String value="DataObject" + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.DataObject) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.DataObject + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .DataObject' + CONST Int type=kotlin.Int value=-1155894359 + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.DataObject, other:kotlin.Any?) returnType:kotlin.Boolean [operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.DataObject + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .DataObject declared in .DataObject.equals' type=.DataObject origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.DataObject + GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.DataObject [val] + TYPE_OP type=.DataObject origin=CAST typeOperand=.DataObject + GET_VAR 'other: kotlin.Any? declared in .DataObject.equals' type=kotlin.Any? origin=null + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .DataObject' + CONST Boolean type=kotlin.Boolean value=true diff --git a/compiler/testData/ir/irText/firProblems/dataObject.kt b/compiler/testData/ir/irText/firProblems/dataObject.kt new file mode 100644 index 00000000000..0784d01d1e7 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/dataObject.kt @@ -0,0 +1,3 @@ +// LANGUAGE: +DataObjects + +data object DataObject diff --git a/compiler/testData/ir/irText/firProblems/dataObject.kt.txt b/compiler/testData/ir/irText/firProblems/dataObject.kt.txt new file mode 100644 index 00000000000..d8fe1cf9268 --- /dev/null +++ b/compiler/testData/ir/irText/firProblems/dataObject.kt.txt @@ -0,0 +1,27 @@ +data object DataObject { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun toString(): String { + return "DataObject" + } + + override fun hashCode(): Int { + return -1155894359 + } + + override operator fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is DataObject -> return false + } + val tmp0_other_with_cast: DataObject = other as DataObject + return true + } + +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 828eb900452..0e21fe2e88d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -2618,6 +2618,12 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/firProblems/coercionToUnitForNestedWhen.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java index 56b6f0478e5..fe294662a50 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java @@ -1900,6 +1900,11 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase { runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt"); } + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { runTest("compiler/testData/ir/irText/firProblems/DeepCopyIrTree.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java index 1943ddd9ed6..97252f359fa 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java @@ -2174,6 +2174,12 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java index ed2b31d07c1..e89b12f270d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java @@ -2174,6 +2174,12 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest { runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java index dfa2002d215..4bf5f51bda8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java @@ -2174,6 +2174,12 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest { runTest("compiler/testData/ir/irText/firProblems/cannotCastToFunction.kt"); } + @Test + @TestMetadata("dataObject.kt") + public void testDataObject() throws Exception { + runTest("compiler/testData/ir/irText/firProblems/dataObject.kt"); + } + @Test @TestMetadata("DeepCopyIrTree.kt") public void testDeepCopyIrTree() throws Exception {