Do not load Java @Repeatable for Kotlin-repeatable annotations

#KT-48131 Fixed
This commit is contained in:
Alexander Udalov
2021-08-06 14:32:17 +02:00
parent 89b3013294
commit f8af127a4e
11 changed files with 131 additions and 19 deletions
@@ -5,9 +5,11 @@
package org.jetbrains.kotlin
import org.jetbrains.kotlin.descriptors.SourceElement
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.kotlin.KotlinJvmBinaryClass
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
object SpecialJvmAnnotations {
val SPECIAL_ANNOTATIONS: Set<ClassId> = listOf(
@@ -18,4 +20,22 @@ object SpecialJvmAnnotations {
JvmAnnotationNames.RETENTION_ANNOTATION,
JvmAnnotationNames.DOCUMENTED_ANNOTATION
).mapTo(mutableSetOf(), ClassId::topLevel)
val JAVA_LANG_ANNOTATION_REPEATABLE = ClassId.topLevel(JvmAnnotationNames.REPEATABLE_ANNOTATION)
fun isAnnotatedWithContainerMetaAnnotation(klass: KotlinJvmBinaryClass): Boolean {
var result = false
klass.loadClassAnnotations(object : KotlinJvmBinaryClass.AnnotationVisitor {
override fun visitAnnotation(classId: ClassId, source: SourceElement): KotlinJvmBinaryClass.AnnotationArgumentVisitor? {
if (classId == JvmAbi.REPEATABLE_ANNOTATION_CONTAINER_META_ANNOTATION) {
result = true
}
return null
}
override fun visitEnd() {
}
}, null)
return result
}
}