diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 8911acf6b02..4d4f9d615e7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -1323,7 +1323,9 @@ public class FunctionCodegen { private boolean isDefaultNeeded(@NotNull FunctionDescriptor descriptor, @Nullable KtNamedFunction function) { List parameters = - CodegenUtil.getFunctionParametersForDefaultValueGeneration(descriptor, state.getDiagnostics()); + CodegenUtil.getFunctionParametersForDefaultValueGeneration( + descriptor.isSuspend() ? CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor) : descriptor, + state.getDiagnostics()); return CollectionsKt.any(parameters, ValueParameterDescriptor::declaresDefaultValue); } diff --git a/compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt b/compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt new file mode 100644 index 00000000000..2c7eeffb586 --- /dev/null +++ b/compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt @@ -0,0 +1,34 @@ +// !LANGUAGE: +MultiPlatformProjects +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// WITH_COROUTINES + +// FILE: lib.kt + +expect interface I { + suspend fun f(p: Int = 1): String +} + +// FILE: main.kt +import kotlin.coroutines.* +import helpers.* + +actual interface I { + actual suspend fun f(p: Int): String +} + +class II : I { + override suspend fun f(p: Int): String = "OK" +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var res = "FAIL" + builder { + res = II().f() + } + return res +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index a653595a71b..db331fa215b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -16638,6 +16638,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt"); } + @TestMetadata("suspend.kt") + public void testSuspend() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt"); + } + @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index bbd6560b840..cf37f5f1a2f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -16638,6 +16638,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/parametersInArgumentValues.kt"); } + @TestMetadata("suspend.kt") + public void testSuspend() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt"); + } + @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 8c59b6e992b..b044eaa98b0 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -15523,6 +15523,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt"); } + @TestMetadata("suspend.kt") + public void testSuspend() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt"); + } + @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index c294230c190..30bc05a15ce 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12738,6 +12738,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt"); } + @TestMetadata("suspend.kt") + public void testSuspend() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt"); + } + @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index fd01c2d120e..081ecda039c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13853,6 +13853,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/superCall.kt"); } + @TestMetadata("suspend.kt") + public void testSuspend() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/suspend.kt"); + } + @TestMetadata("typeAlias.kt") public void testTypeAlias() throws Exception { runTest("compiler/testData/codegen/box/multiplatform/defaultArguments/typeAlias.kt");