[SLC] LazyAnnotationsBox: fix case with empty AnnotationsProvider

^KT-56046
This commit is contained in:
Dmitrii Gridin
2023-01-25 14:36:07 +01:00
committed by Space Team
parent e4795a9082
commit 6a65708631
@@ -28,10 +28,7 @@ internal class LazyAnnotationsBox(
SymbolLightLazyAnnotation(classId, annotationsProvider, index, owner) SymbolLightLazyAnnotation(classId, annotationsProvider, index, owner)
} }
val valueToReturn = if (annotations.isEmpty()) { val valueToReturn = synchronized(monitor) {
setAnnotationsArray(PsiAnnotation.EMPTY_ARRAY)
} else {
synchronized(monitor) {
specialAnnotations?.forEach { specialAnnotation -> specialAnnotations?.forEach { specialAnnotation ->
val index = annotations.indexOfFirst { it.qualifiedName == specialAnnotation.qualifiedName } val index = annotations.indexOfFirst { it.qualifiedName == specialAnnotation.qualifiedName }
if (index != -1) { if (index != -1) {
@@ -41,12 +38,11 @@ internal class LazyAnnotationsBox(
} }
} }
val foundQualifiers = hashSetOf<String>() val foundQualifiers = annotations.mapNotNullTo(hashSetOf()) { it.qualifiedName }
additionalAnnotationsProvider.addAllAnnotations(annotations, foundQualifiers, owner) additionalAnnotationsProvider.addAllAnnotations(annotations, foundQualifiers, owner)
specialAnnotations = null specialAnnotations = null
setAnnotationsArray(annotations.toTypedArray()) setAnnotationsArray(if (annotations.isNotEmpty()) annotations.toTypedArray() else PsiAnnotation.EMPTY_ARRAY)
}
} }
return valueToReturn return valueToReturn