KT-46797 Generate generic signatures for suspendImpl
This commit is contained in:
+6
@@ -9981,6 +9981,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/generate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericSignatureForSuspendImpl.kt")
|
||||
public void testGenericSignatureForSuspendImpl() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/genericSignatureForSuspendImpl.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("handleException.kt")
|
||||
public void testHandleException() throws Exception {
|
||||
|
||||
+2
-1
@@ -60,7 +60,8 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg
|
||||
signature.genericsSignature
|
||||
.takeIf {
|
||||
(irFunction.isInline && irFunction.origin != IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) ||
|
||||
!isSynthetic && irFunction.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA
|
||||
(!isSynthetic && irFunction.origin != IrDeclarationOrigin.LOCAL_FUNCTION_FOR_LAMBDA) ||
|
||||
(irFunction.origin == JvmLoweredDeclarationOrigin.SUSPEND_IMPL_STATIC_FUNCTION)
|
||||
},
|
||||
getThrownExceptions(irFunction)?.toTypedArray()
|
||||
)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FULL_JDK
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import java.lang.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
open class MyClass {
|
||||
open suspend fun <T> fooTypeParameter() = reifiedType<Foo<T>>()
|
||||
}
|
||||
|
||||
class Foo<T>
|
||||
|
||||
open class TypeBase<T>
|
||||
|
||||
inline fun <reified T> reifiedType(): Type {
|
||||
val base = object : TypeBase<T>() {}
|
||||
val superType = base::class.java.genericSuperclass!!
|
||||
return (superType as ParameterizedType).actualTypeArguments.first()!!
|
||||
}
|
||||
|
||||
fun runBlocking(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext){
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
runBlocking {
|
||||
assertEquals("test.Foo<T>", MyClass().fooTypeParameter<String>().toString())
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -9861,6 +9861,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/generate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericSignatureForSuspendImpl.kt")
|
||||
public void testGenericSignatureForSuspendImpl() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/genericSignatureForSuspendImpl.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("handleException.kt")
|
||||
public void testHandleException() throws Exception {
|
||||
|
||||
+6
@@ -9981,6 +9981,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/generate.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("genericSignatureForSuspendImpl.kt")
|
||||
public void testGenericSignatureForSuspendImpl() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/genericSignatureForSuspendImpl.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("handleException.kt")
|
||||
public void testHandleException() throws Exception {
|
||||
|
||||
+5
@@ -7759,6 +7759,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/generate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericSignatureForSuspendImpl.kt")
|
||||
public void testGenericSignatureForSuspendImpl() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/genericSignatureForSuspendImpl.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("handleException.kt")
|
||||
public void testHandleException() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/handleException.kt");
|
||||
|
||||
Reference in New Issue
Block a user