Check default parameters of expect suspend functions on original

functions instead of function views.
 #KT-24461 Fixed
This commit is contained in:
Ilmir Usmanov
2019-11-12 16:27:58 +03:00
parent 633d1c9ea3
commit ea5b529d19
7 changed files with 62 additions and 1 deletions
@@ -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
}
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");