From 0efc819e484404fa2eba1178744942ec07cd259b Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 21 Dec 2021 14:15:00 +0300 Subject: [PATCH] Fix invalid repeatable annotations loading in sutb builder --- .../decompiler/stub/file/KotlinClsStubBuilder.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/analysis/decompiled/decompiler-to-file-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/file/KotlinClsStubBuilder.kt b/analysis/decompiled/decompiler-to-file-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/file/KotlinClsStubBuilder.kt index df5f884f78b..daa30109cf8 100644 --- a/analysis/decompiled/decompiler-to-file-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/file/KotlinClsStubBuilder.kt +++ b/analysis/decompiled/decompiler-to-file-stubs/src/org/jetbrains/kotlin/analysis/decompiler/stub/file/KotlinClsStubBuilder.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.SpecialJvmAnnotations import org.jetbrains.kotlin.analysis.decompiler.stub.* import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.deserialization.common.jvm.impl.VirtualFileKotlinClass +import org.jetbrains.kotlin.load.java.JvmAnnotationNames import org.jetbrains.kotlin.load.kotlin.* import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader import org.jetbrains.kotlin.metadata.ProtoBuf @@ -158,10 +159,9 @@ private class AnnotationLoaderForClassFileStubBuilder( } override fun visitEnd() { - // todo -// if (!isRepeatableWithImplicitContainer(annotationClassId, arguments)) { -// result.add(annotationClassId) -// } + if (!isRepeatableWithImplicitContainer(annotationClassId, arguments)) { + result.add(annotationClassId) + } } override fun visit(name: Name?, value: Any?) = Unit @@ -171,6 +171,14 @@ private class AnnotationLoaderForClassFileStubBuilder( } } + protected fun isRepeatableWithImplicitContainer(annotationClassId: ClassId, arguments: Map>): Boolean { + if (annotationClassId != SpecialJvmAnnotations.JAVA_LANG_ANNOTATION_REPEATABLE) return false + + val containerKClassValue = arguments[JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME] as? KClassValue ?: return false + val normalClass = containerKClassValue.value as? KClassValue.Value.NormalClass ?: return false + return isImplicitRepeatableContainer(normalClass.classId) + } + private fun loadAnnotationsAndInitializers(kotlinClass: KotlinJvmBinaryClass): AnnotationsClassIdContainer { val memberAnnotations = HashMap>()