From d397efb2bd81392ccb995e7c12b05d40d6c94bcf Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Mon, 10 May 2021 15:57:31 +0200 Subject: [PATCH] [JVM IR] Copy attributes for JVM_STATIC_WRAPPERS. --- .../FirBlackBoxCodegenTestGenerated.java | 6 +++ .../backend/jvm/JvmCachedDeclarations.kt | 1 + .../box/coroutines/jvmStaticAndJvmInline.kt | 38 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../IrJsCodegenBoxES6TestGenerated.java | 5 --- .../IrJsCodegenBoxTestGenerated.java | 5 --- .../semantics/JsCodegenBoxTestGenerated.java | 5 --- .../IrCodegenBoxWasmTestGenerated.java | 5 --- 10 files changed, 62 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt 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 941193bcd7b..55b627ae7fe 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 @@ -9084,6 +9084,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); } + @Test + @TestMetadata("jvmStaticAndJvmInline.kt") + public void testJvmStaticAndJvmInline() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt"); + } + @Test @TestMetadata("kt12958.kt") public void testKt12958() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt index d3dae034822..c3b93fdf2e1 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt @@ -196,6 +196,7 @@ class JvmCachedDeclarations( isSuspend = target.isSuspend }.apply proxy@{ parent = this@makeProxy + copyAttributes(target) copyTypeParametersFrom(target) copyAnnotationsFrom(target) if (!isStatic) { diff --git a/compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt b/compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt new file mode 100644 index 00000000000..1889b8a0319 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt @@ -0,0 +1,38 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// WITH_COROUTINES +import helpers.* +import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +suspend fun suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn { + it.resume(x) + COROUTINE_SUSPENDED +} + +inline class I(val x: Any?) + +open class C { + companion object { + @JvmStatic + protected suspend fun f(): I = I(suspendHere("OK")) + } +} + +class D : C() { + companion object { + suspend fun g() = f() + } +} + +fun box(): String { + var result = "FAIL" + builder { + result = D.g().x as String + } + return result +} 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 e3ef64139e7..7458bb89d14 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 @@ -9084,6 +9084,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); } + @Test + @TestMetadata("jvmStaticAndJvmInline.kt") + public void testJvmStaticAndJvmInline() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt"); + } + @Test @TestMetadata("kt12958.kt") public void testKt12958() 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 635f8522a2c..225e73d0485 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 @@ -9084,6 +9084,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); } + @Test + @TestMetadata("jvmStaticAndJvmInline.kt") + public void testJvmStaticAndJvmInline() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt"); + } + @Test @TestMetadata("kt12958.kt") public void testKt12958() 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 589a95498eb..46a582025c8 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -7104,6 +7104,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/iterateOverArray.kt"); } + @TestMetadata("jvmStaticAndJvmInline.kt") + public void testJvmStaticAndJvmInline() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/jvmStaticAndJvmInline.kt"); + } + @TestMetadata("kt12958.kt") public void testKt12958() throws Exception { runTest("compiler/testData/codegen/box/coroutines/kt12958.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 76bbdeb5c2b..04c5f94f467 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -15960,11 +15960,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/jvmStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } - @TestMetadata("kt46568.kt") - public void testKt46568() throws Exception { - runTest("compiler/testData/codegen/box/jvmStatic/kt46568.kt"); - } - @TestMetadata("compiler/testData/codegen/box/jvmStatic/protectedInSuperClass") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 712fb5f39e0..034dedea3bb 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -15371,11 +15371,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/jvmStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } - @TestMetadata("kt46568.kt") - public void testKt46568() throws Exception { - runTest("compiler/testData/codegen/box/jvmStatic/kt46568.kt"); - } - @TestMetadata("compiler/testData/codegen/box/jvmStatic/protectedInSuperClass") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index fa68b100dd6..063be31b933 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -15436,11 +15436,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/jvmStatic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } - @TestMetadata("kt46568.kt") - public void testKt46568() throws Exception { - runTest("compiler/testData/codegen/box/jvmStatic/kt46568.kt"); - } - @TestMetadata("compiler/testData/codegen/box/jvmStatic/protectedInSuperClass") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index edcdd8b3968..f8c4feb0d11 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -9181,11 +9181,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/jvmStatic"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); } - @TestMetadata("kt46568.kt") - public void testKt46568() throws Exception { - runTest("compiler/testData/codegen/box/jvmStatic/kt46568.kt"); - } - @TestMetadata("compiler/testData/codegen/box/jvmStatic/protectedInSuperClass") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)