Check default parameters of expect suspend functions on original
functions instead of function views. #KT-24461 Fixed
This commit is contained in:
@@ -1323,7 +1323,9 @@ public class FunctionCodegen {
|
||||
|
||||
private boolean isDefaultNeeded(@NotNull FunctionDescriptor descriptor, @Nullable KtNamedFunction function) {
|
||||
List<ValueParameterDescriptor> parameters =
|
||||
CodegenUtil.getFunctionParametersForDefaultValueGeneration(descriptor, state.getDiagnostics());
|
||||
CodegenUtil.getFunctionParametersForDefaultValueGeneration(
|
||||
descriptor.isSuspend() ? CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(descriptor) : descriptor,
|
||||
state.getDiagnostics());
|
||||
return CollectionsKt.any(parameters, ValueParameterDescriptor::declaresDefaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user