Do not write generics for $suspendImpl synthetic method

#KT-18252 Fixed
This commit is contained in:
Denis Zharkov
2017-06-28 10:24:13 +03:00
parent e7e0032cc8
commit 3dc4f8a2ff
5 changed files with 85 additions and 0 deletions
@@ -229,6 +229,13 @@ public class FunctionCodegen {
}
asmMethod = CoroutineCodegenUtilKt.getImplForOpenMethod(asmMethod, v.getThisName());
// remove generic signature as it's unnecessary for synthetic methods
jvmSignature =
new JvmMethodGenericSignature(
asmMethod,
jvmSignature.getValueParameters(),
null
);
mv.visitMethodInsn(
Opcodes.INVOKESTATIC,
@@ -0,0 +1,60 @@
// WITH_RUNTIME
// WITH_COROUTINES
// FILE: main.kt
// TARGET_BACKEND: JVM
import helpers.*
import kotlin.coroutines.experimental.*
import kotlin.coroutines.experimental.intrinsics.*
open class A(val v: String) {
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
x.resume(v)
COROUTINE_SUSPENDED
}
open suspend fun suspendHere(): String = suspendThere("O") + suspendThere(v)
}
class B(v: String) : A(v) {
override suspend fun suspendHere(): String = super.suspendHere() + suspendThere("56")
}
fun builder(c: suspend A.() -> Unit) {
c.startCoroutine(B("K"), EmptyContinuation)
}
fun box(): String {
var result = JavaClass.foo()
if (result != "OK56") return "fail 1: $result"
return "OK"
}
// FILE: JavaClass.java
import kotlin.coroutines.experimental.*;
public class JavaClass {
public static String foo() {
final String[] res = new String[1];
new B("K").suspendHere(new Continuation<String>() {
@Override
public CoroutineContext getContext() {
return EmptyCoroutineContext.INSTANCE;
}
@Override
public void resume(String s) {
res[0] = s;
}
@Override
public void resumeWithException(Throwable throwable) {
}
});
return res[0];
}
}
@@ -5704,6 +5704,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("openFunWithJava.kt")
public void testOpenFunWithJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/openFunWithJava.kt");
doTest(fileName);
}
@TestMetadata("operators.kt")
public void testOperators() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/operators.kt");
@@ -5704,6 +5704,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("openFunWithJava.kt")
public void testOpenFunWithJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/openFunWithJava.kt");
doTest(fileName);
}
@TestMetadata("operators.kt")
public void testOperators() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/operators.kt");
@@ -5704,6 +5704,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("openFunWithJava.kt")
public void testOpenFunWithJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/openFunWithJava.kt");
doTest(fileName);
}
@TestMetadata("operators.kt")
public void testOperators() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/coroutines/suspendFunctionAsCoroutine/operators.kt");