diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 99da23f71e1..6c994ffceb7 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -35689,6 +35689,30 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("javaGenericSynthProperty.kt") public void testJavaGenericSynthProperty() throws Exception { diff --git a/compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt b/compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt new file mode 100644 index 00000000000..18957651554 --- /dev/null +++ b/compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt @@ -0,0 +1,19 @@ +// KT-56023 +// JS_IR: InterpreterError: Unsupported number of arguments for invocation as builtin function: four +// NATIVE: in mode -Pkotlin.internal.native.test.mode=TWO_STAGE_MULTI_MODULE (default test mode), test fails as below +// InterpreterError: Unsupported number of arguments for invocation as builtin function: four +// in mode -Pkotlin.internal.native.test.mode=ONE_STAGE_MULTI_MODULE, test passes +// IGNORE_BACKEND_K2: NATIVE, JS_IR + +// MODULE: lib +// FILE: lib.kt +const val four = 4 + +// MODULE: main(lib) +// FILE: main.kt +fun box(): String { + if (four == 4) + return "OK" + else + return four.toString() +} diff --git a/compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt b/compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt new file mode 100644 index 00000000000..6e80b804713 --- /dev/null +++ b/compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt @@ -0,0 +1,18 @@ +// KT-56023 +// JS_IR: IllegalStateException: CONST_VAL_WITH_NON_CONST_INITIALIZER: Const 'val' initializer should be a constant value at (7,18) in /lib.kt +// NATIVE: test fails as below in both modes -Pkotlin.internal.native.test.mode=TWO_STAGE_MULTI_MODULE, -Pkotlin.internal.native.test.mode=ONE_STAGE_MULTI_MODULE +// error: const 'val' initializer should be a constant value +// IGNORE_BACKEND_K2: NATIVE, JS_IR + +// MODULE: lib +// FILE: lib.kt +const val four = 2 + 2 + +// MODULE: main(lib) +// FILE: main.kt +fun box(): String { + if (four == 4) + return "OK" + else + return four.toString() +} diff --git a/compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt b/compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt new file mode 100644 index 00000000000..3882c1814c2 --- /dev/null +++ b/compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt @@ -0,0 +1,12 @@ +// MODULE: lib +// FILE: lib.kt +val four = 2 + 2 + +// MODULE: main(lib) +// FILE: main.kt +fun box(): String { + if (four == 4) + return "OK" + else + return four.toString() +} diff --git a/compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt b/compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt new file mode 100644 index 00000000000..a7650be95bc --- /dev/null +++ b/compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt @@ -0,0 +1,16 @@ +// MODULE: lib1 +// FILE: lib1.kt +fun initializer() = 4 + +// MODULE: lib2(lib1) +// FILE: lib2.kt +val four = initializer() + +// MODULE: main(lib1, lib2) +// FILE: main.kt +fun box(): String { + if (four == 4) + return "OK" + else + return four.toString() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index e4545667077..cd0a80f3ba5 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -34363,6 +34363,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("javaGenericSynthProperty.kt") public void testJavaGenericSynthProperty() throws Exception { 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 4dde1c726cc..3abf90b3763 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 @@ -35689,6 +35689,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("javaGenericSynthProperty.kt") public void testJavaGenericSynthProperty() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 7406598b807..da7d4e88743 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -29314,6 +29314,26 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @TestMetadata("javaGenericSynthProperty.kt") public void testJavaGenericSynthProperty() throws Exception { runTest("compiler/testData/codegen/box/properties/javaGenericSynthProperty.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index c2907fa58a2..40a39ad6017 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -25173,6 +25173,30 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index af60f4a873c..348809c0936 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -25209,6 +25209,30 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index d93f384e13b..fe2be8533f4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -25209,6 +25209,30 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 855a3b78d9e..e5ac302ab10 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -25209,6 +25209,30 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java index 33de7461055..f154bf62590 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/K2NativeCodegenBoxTestGenerated.java @@ -28375,6 +28375,30 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 18565d71ce7..96d85f50e80 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -28052,6 +28052,30 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @Test + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @Test + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @Test + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @Test @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index c85df56b4b3..adbb2760305 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -22517,6 +22517,26 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt"); } + @TestMetadata("initializerOfConstValWithConst.kt") + public void testInitializerOfConstValWithConst() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConst.kt"); + } + + @TestMetadata("initializerOfConstValWithConstExpr.kt") + public void testInitializerOfConstValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfConstValWithConstExpr.kt"); + } + + @TestMetadata("initializerOfValWithConstExpr.kt") + public void testInitializerOfValWithConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithConstExpr.kt"); + } + + @TestMetadata("initializerOfValWithNonConstExpr.kt") + public void testInitializerOfValWithNonConstExpr() throws Exception { + runTest("compiler/testData/codegen/box/properties/initializerOfValWithNonConstExpr.kt"); + } + @TestMetadata("kt10715.kt") public void testKt10715() throws Exception { runTest("compiler/testData/codegen/box/properties/kt10715.kt");