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 7496530424d..2a5e087f59f 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 @@ -9828,12 +9828,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -10663,6 +10657,34 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index 11faed50a26..0535c9c01ec 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -385,8 +385,13 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower // the result is called 'view', just to be consistent with old backend. private fun IrSimpleFunction.suspendFunctionViewOrStub(context: JvmBackendContext): IrSimpleFunction { if (!isSuspend) return this + // If superinterface is in another file, the bridge to default method will already have continuation parameter, + // so skip it. See KT-47549. + if (origin == JvmLoweredDeclarationOrigin.SUPER_INTERFACE_METHOD_BRIDGE && + valueParameters.lastOrNull()?.origin == JvmLoweredDeclarationOrigin.CONTINUATION_CLASS + ) return this // We need to use suspend function originals here, since if we use 'this' here, - // turing FlowCollector into 'fun interface' leads to AbstractMethodError + // turing FlowCollector into 'fun interface' leads to AbstractMethodError. See KT-49294. return context.suspendFunctionOriginalToView.getOrPut(suspendFunctionOriginal()) { createSuspendFunctionStub(context) } } diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt new file mode 100644 index 00000000000..5c80642e49f --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt @@ -0,0 +1,12 @@ +// WITH_STDLIB + +// FILE: 1.kt +fun interface I { + fun f(): String + + suspend fun s() {} +} + +// FILE: box.kt +fun box(): String = + I { "OK" }.f() diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt new file mode 100644 index 00000000000..54e0e64ea9c --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt @@ -0,0 +1,10 @@ +// WITH_STDLIB + +fun interface I { + fun f(): String + + suspend fun s() {} +} + +fun box(): String = + I { "OK" }.f() diff --git a/compiler/testData/codegen/box/coroutines/kt49294.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt similarity index 100% rename from compiler/testData/codegen/box/coroutines/kt49294.kt rename to compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt 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 d0232b76085..4438aa392fb 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 @@ -9750,12 +9750,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -10585,6 +10579,34 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") 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 8b289ede9a3..373155dcbd3 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 @@ -9828,12 +9828,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -10663,6 +10657,34 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 48ab1b63255..2ba741c2e43 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -7280,11 +7280,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @TestMetadata("kt49294.kt") - public void ignoreKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @TestMetadata("suspendFunctionAsSupertype.kt") public void ignoreSuspendFunctionAsSupertype() throws Exception { runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt"); @@ -8366,6 +8361,34 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunInterface extends AbstractLightAnalysisModeTest { + @TestMetadata("kt49294.kt") + public void ignoreKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) 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 ed74e99e0bb..8641be6e7b4 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 @@ -6968,12 +6968,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -7701,6 +7695,34 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") 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 20827c87af3..79e61c7e733 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 @@ -7010,12 +7010,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -7743,6 +7737,34 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 382e1b9aa1a..928e6170188 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -6060,11 +6060,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt"); @@ -6708,6 +6703,34 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FunInterface extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java index 68a5945d244..128ce5ab358 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java @@ -9931,12 +9931,6 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest { runTest("compiler/testData/codegen/box/coroutines/kt49168.kt"); } - @Test - @TestMetadata("kt49294.kt") - public void testKt49294() throws Exception { - runTest("compiler/testData/codegen/box/coroutines/kt49294.kt"); - } - @Test @TestMetadata("lastExpressionIsLoop.kt") public void testLastExpressionIsLoop() throws Exception { @@ -10774,6 +10768,35 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface") + @TestDataPath("$PROJECT_ROOT") + @NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class) + public class FunInterface { + @Test + public void testAllFilesPresentInFunInterface() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @Test + @TestMetadata("kt47549.kt") + public void testKt47549() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549.kt"); + } + + @Test + @TestMetadata("kt47549_1.kt") + public void testKt47549_1() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt47549_1.kt"); + } + + @Test + @TestMetadata("kt49294.kt") + public void testKt49294() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/funInterface/kt49294.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault") @TestDataPath("$PROJECT_ROOT")