JVM/JVM_IR: fix mapping of KClass in annotation classes
* JVM incorrectly mapped T<KClass<...>> to T<Class<...>> because the annotation-ness of the type mapping mode was inherited one level down into a generic signature independent of T * JVM_IR was even worse as it did not use VALUE_FOR_ANNOTATION at all, mapping T<T<KClass<...>> to T<T<Class<...>> as well. The correct behavior is to map KClass to Class only at top level or as an argument of Array.
This commit is contained in:
+1
-1
@@ -137,7 +137,7 @@ class IrTypeMapper(private val context: JvmBackendContext) : KotlinTypeMapperBas
|
||||
arrayElementType = AsmTypes.OBJECT_TYPE
|
||||
sw?.writeClass(arrayElementType)
|
||||
} else {
|
||||
arrayElementType = mapType(memberType, mode.toGenericArgumentMode(variance), sw)
|
||||
arrayElementType = mapType(memberType, mode.toGenericArgumentMode(variance, ofArray = true), sw)
|
||||
}
|
||||
sw?.writeArrayEnd()
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val arg: Array<out KClass<out KClass<*>>>)
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val arg: KClass<out KClass<*>>)
|
||||
|
||||
// method: Ann::arg
|
||||
// jvm signature: ()Ljava/lang/Class;
|
||||
// generic signature: ()Ljava/lang/Class<+Lkotlin/reflect/KClass<*>;>;
|
||||
+5
@@ -170,6 +170,11 @@ public class IrWriteSignatureTestGenerated extends AbstractIrWriteSignatureTest
|
||||
public void testKClassInt() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/annotations/kClassInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kClassOfKClass.kt")
|
||||
public void testKClassOfKClass() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/annotations/kClassOfKClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeSignature/callableReference")
|
||||
|
||||
+5
@@ -169,6 +169,11 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
|
||||
public void testKClassInt() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/annotations/kClassInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kClassOfKClass.kt")
|
||||
public void testKClassOfKClass() throws Exception {
|
||||
runTest("compiler/testData/writeSignature/annotations/kClassOfKClass.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/writeSignature/callableReference")
|
||||
|
||||
Reference in New Issue
Block a user