Support array of annotation in KotlinJvmBinaryClass
KotlinJvmBinaryClass.AnnotationArrayArgumentVisitor didn't cover the
case when the element type is an Annotation. Therefore, when the
compiler read an array of annotations from JVM binary classes built from
Kotlin sources, it got an empty array regardless of what was written in
the bytecode.
For example, Foo.value below is read as an empty array when SomeClass
resides in another Kotlin module.
@Foo(
value = [Bar(1), Bar(2)]
)
class SomeClass
This commit is contained in:
committed by
Alexander Udalov
parent
5e392a511f
commit
6c989bfd4b
+4
@@ -243,6 +243,10 @@ private object ReflectClassStructure {
|
||||
componentType == Class::class.java -> for (element in value as Array<*>) {
|
||||
v.visitClassLiteral((element as Class<*>).classLiteralValue())
|
||||
}
|
||||
Annotation::class.java.isAssignableFrom(componentType) -> for (element in value as Array<*>) {
|
||||
val vv = v.visitAnnotation(componentType.classId) ?: continue
|
||||
processAnnotationArguments(vv, element as Annotation, componentType)
|
||||
}
|
||||
else -> for (element in value as Array<*>) {
|
||||
v.visit(element)
|
||||
}
|
||||
|
||||
+5
@@ -58,6 +58,11 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInAnnotationArguments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("AnnotationInArray.kt")
|
||||
public void testAnnotationInArray() throws Exception {
|
||||
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ClassLiteralArguments.kt")
|
||||
public void testClassLiteralArguments() throws Exception {
|
||||
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
|
||||
|
||||
Reference in New Issue
Block a user