JVM_IR: remove a suspend-related hack from BridgeLowering
`invoke` in suspend lambdas overrides FunctionN.invoke, so the refactored BridgeLowering already generates correct bridges there. All the hack does is break overrides of interface suspend methods.
This commit is contained in:
+1
-6
@@ -463,12 +463,7 @@ private class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass,
|
||||
|
||||
private fun IrValueParameter.copyWithTypeErasure(target: IrSimpleFunction, forceBoxing: Boolean = false): IrValueParameter = copyTo(
|
||||
target, IrDeclarationOrigin.BRIDGE,
|
||||
type =
|
||||
// SuspendFunction{N} is Function{N+1} at runtime, thus, when we generate a bridge for suspend callable references,
|
||||
// we need to replace the type of its continuation parameter with Any?
|
||||
if (target.isSuspend && type.eraseTypeParameters().getClass()
|
||||
?.fqNameWhenAvailable == DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE
|
||||
) context.irBuiltIns.anyNType else type.eraseTypeParameters().let { if (forceBoxing) it.makeNullable() else it },
|
||||
type = type.eraseTypeParameters().let { if (forceBoxing) it.makeNullable() else it },
|
||||
varargElementType = varargElementType?.eraseTypeParameters()
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import helpers.*
|
||||
import COROUTINES_PACKAGE.*
|
||||
|
||||
interface I1<A, B> {
|
||||
suspend fun f(a: A, b: B): String
|
||||
}
|
||||
|
||||
class C<A> : I1<A, String> {
|
||||
override suspend fun f(a: A, b: String): String = b
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
suspend {
|
||||
result = (C<Unit>() as I1<Unit, String>).f(Unit, "OK")
|
||||
}.startCoroutine(EmptyContinuation)
|
||||
return result
|
||||
}
|
||||
+10
@@ -6908,6 +6908,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines.experimental");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
+10
@@ -6908,6 +6908,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines.experimental");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_2() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines.experimental");
|
||||
|
||||
+5
@@ -6453,6 +6453,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
|
||||
|
||||
+5
@@ -6453,6 +6453,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
|
||||
|
||||
Generated
+5
@@ -5483,6 +5483,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
|
||||
|
||||
+5
@@ -5483,6 +5483,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/coroutines/bridges"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("interfaceSpecialization.kt")
|
||||
public void testInterfaceSpecialization_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/interfaceSpecialization.kt", "kotlin.coroutines");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaWithLongReceiver.kt")
|
||||
public void testLambdaWithLongReceiver_1_3() throws Exception {
|
||||
runTestWithPackageReplacement("compiler/testData/codegen/box/coroutines/bridges/lambdaWithLongReceiver.kt", "kotlin.coroutines");
|
||||
|
||||
Reference in New Issue
Block a user