Generate correct $default method for actual suspend function
In order to do this, we need to get initial expect suspend function before generating default value parameters checks. #KT-43587 Fixed
This commit is contained in:
@@ -1221,7 +1221,12 @@ public class FunctionCodegen {
|
||||
|
||||
// 'null' because the "could not find expected declaration" error has been already reported in isDefaultNeeded earlier
|
||||
List<ValueParameterDescriptor> 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);
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
+25
@@ -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"
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user