JVM IR: Fix suspend lambda generic signatures
This commit is contained in:
committed by
Ilmir Usmanov
parent
e6efb81014
commit
272f6abe69
+1
-1
@@ -164,7 +164,7 @@ private class AddContinuationLowering(private val context: JvmBackendContext) :
|
|||||||
functionNClass,
|
functionNClass,
|
||||||
hasQuestionMark = false,
|
hasQuestionMark = false,
|
||||||
arguments = (info.function.explicitParameters.subList(0, info.arity).map { it.type }
|
arguments = (info.function.explicitParameters.subList(0, info.arity).map { it.type }
|
||||||
+ info.function.continuationType() + info.function.returnType)
|
+ info.function.continuationType() + context.irBuiltIns.anyNType)
|
||||||
.map { makeTypeProjection(it, Variance.INVARIANT) },
|
.map { makeTypeProjection(it, Variance.INVARIANT) },
|
||||||
annotations = emptyList()
|
annotations = emptyList()
|
||||||
)
|
)
|
||||||
|
|||||||
Vendored
+73
@@ -0,0 +1,73 @@
|
|||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|
||||||
|
import java.util.Date
|
||||||
|
|
||||||
|
fun assertEquals(expected: String, actual: Any) {
|
||||||
|
if ("$actual" != expected)
|
||||||
|
throw AssertionError("Fail, expected: $expected, actual: $actual")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertGenericSuper(expected: String, function: Any?) {
|
||||||
|
val clazz = (function as java.lang.Object).getClass()!!
|
||||||
|
val genericSuper = clazz.getGenericInterfaces()[0]!!
|
||||||
|
assertEquals(expected, genericSuper)
|
||||||
|
}
|
||||||
|
|
||||||
|
val unitFun = suspend { }
|
||||||
|
val intFun = suspend { 42 }
|
||||||
|
|
||||||
|
fun assertStringParamFun(lambda: suspend (String) -> Unit) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function2<java.lang.String, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertListFun(lambda: suspend (List<String>) -> Unit) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function2<java.util.List<? extends java.lang.String>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertMutableListFun(lambda: suspend (MutableList<Double>) -> MutableList<Int>) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function2<java.util.List<java.lang.Double>, kotlin.coroutines.Continuation<? super java.util.List<java.lang.Integer>>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertFunWithIn(lambda: suspend (Comparable<String>) -> Unit) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function2<java.lang.Comparable<? super java.lang.String>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertExtensionFun(lambda: suspend Any.() -> Unit) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function2<java.lang.Object, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun assertExtensionWithArgFun(lambda: suspend Long.(x: Any) -> Date) {
|
||||||
|
assertEquals(
|
||||||
|
"kotlin.jvm.functions.Function3<java.lang.Long, java.lang.Object, kotlin.coroutines.Continuation<? super java.util.Date>, java.lang.Object>",
|
||||||
|
lambda.javaClass.genericInterfaces.single()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
assertGenericSuper("kotlin.jvm.functions.Function1<kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object>", unitFun)
|
||||||
|
assertGenericSuper("kotlin.jvm.functions.Function1<kotlin.coroutines.Continuation<? super java.lang.Integer>, java.lang.Object>", intFun)
|
||||||
|
assertStringParamFun { x: String -> }
|
||||||
|
assertListFun { l: List<String> -> l }
|
||||||
|
assertMutableListFun { l -> null!! }
|
||||||
|
assertFunWithIn { x -> }
|
||||||
|
assertExtensionFun { }
|
||||||
|
assertExtensionWithArgFun { x -> Date() }
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -24420,6 +24420,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendFunctionLiteralGenericSignature.kt")
|
||||||
|
public void testSuspendFunctionLiteralGenericSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/suspendFunctionLiteralGenericSignature.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
||||||
|
|||||||
+5
@@ -23237,6 +23237,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendFunctionLiteralGenericSignature.kt")
|
||||||
|
public void testSuspendFunctionLiteralGenericSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/suspendFunctionLiteralGenericSignature.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
||||||
|
|||||||
+5
@@ -22924,6 +22924,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendFunctionLiteralGenericSignature.kt")
|
||||||
|
public void testSuspendFunctionLiteralGenericSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/suspendFunctionLiteralGenericSignature.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
||||||
|
|||||||
+5
@@ -22924,6 +22924,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
public void testSignatureOfSimpleInnerSimpleOuter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/signatureOfSimpleInnerSimpleOuter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("suspendFunctionLiteralGenericSignature.kt")
|
||||||
|
public void testSuspendFunctionLiteralGenericSignature() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/reflection/genericSignature/suspendFunctionLiteralGenericSignature.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
@TestMetadata("compiler/testData/codegen/box/reflection/isInstance")
|
||||||
|
|||||||
Reference in New Issue
Block a user