diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 70e2d6844cf..5466c5c4d96 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -1221,7 +1221,12 @@ public class FunctionCodegen { // 'null' because the "could not find expected declaration" error has been already reported in isDefaultNeeded earlier List valueParameters = - CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null); + functionDescriptor.isSuspend() + ? CollectionsKt.plus( + CodegenUtil.getFunctionParametersForDefaultValueGeneration( + CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(functionDescriptor), null), + CollectionsKt.last(functionDescriptor.getValueParameters())) + : CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null); boolean isStatic = isStaticMethod(methodContext.getContextKind(), functionDescriptor); FrameMap frameMap = createFrameMap(state, signature, functionDescriptor.getExtensionReceiverParameter(), valueParameters, isStatic); diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 27b1a4b67fd..99dfee1d850 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -7356,6 +7356,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines"); diff --git a/compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt b/compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt new file mode 100644 index 00000000000..ed82d02b1ba --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +MultiPlatformProjects +// KJS_WITH_FULL_RUNTIME +// WITH_RUNTIME +// IGNORE_BACKEND_FIR: JVM_IR + +import kotlin.coroutines.* + +var res = 0L + +expect suspend fun withLimit(limit: Long = 42L) + +actual suspend fun withLimit(limit: Long) { + res = limit +} + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(Continuation(EmptyCoroutineContext) {}) +} + +fun box(): String { + builder { + withLimit() + } + return if (res == 42L) "OK" else "FAIL $res" +} diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index c1bae21017f..b1c26de07bb 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -7951,6 +7951,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3ac4543710b..050474433c5 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -7956,6 +7956,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index ac5cbfb6d24..ca2ec69d0ee 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -7356,6 +7356,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines"); 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 1d871a46593..071916bd0a2 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 @@ -6121,6 +6121,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines"); 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 9618f4ee91b..b3c5cdbfc7a 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 @@ -6121,6 +6121,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines"); 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 599b2492b45..6fd9d930afc 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 @@ -6121,6 +6121,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/breakWithNonEmptyStack.kt", "kotlin.coroutines"); } + @TestMetadata("defaultExpect.kt") + public void testDefaultExpect() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/featureIntersection/defaultExpect.kt"); + } + @TestMetadata("delegate.kt") public void testDelegate_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/featureIntersection/delegate.kt", "kotlin.coroutines");