[SLC] AnnotationsProvider: replace isTheSameAs with regular equals

^KT-56046
This commit is contained in:
Dmitrii Gridin
2023-02-01 20:27:30 +01:00
committed by Space Team
parent cce933907f
commit cf713d31ef
5 changed files with 8 additions and 9 deletions
@@ -13,6 +13,5 @@ internal sealed interface AnnotationsProvider {
fun annotationInfos(): List<KtAnnotationApplicationInfo> fun annotationInfos(): List<KtAnnotationApplicationInfo>
operator fun get(classId: ClassId): Collection<KtAnnotationApplicationWithArgumentsInfo> operator fun get(classId: ClassId): Collection<KtAnnotationApplicationWithArgumentsInfo>
operator fun contains(classId: ClassId): Boolean operator fun contains(classId: ClassId): Boolean
fun isTheSameAs(other: Any?): Boolean
fun ownerClassId(): ClassId? fun ownerClassId(): ClassId?
} }
@@ -26,12 +26,11 @@ internal class CompositeAnnotationsProvider(val providers: Collection<Annotation
override fun contains(classId: ClassId): Boolean = providers.any { classId in it } override fun contains(classId: ClassId): Boolean = providers.any { classId in it }
override fun isTheSameAs(other: Any?): Boolean = other === this || override fun equals(other: Any?): Boolean = other === this ||
other is CompositeAnnotationsProvider && other is CompositeAnnotationsProvider &&
other.providers.size == providers.size && other.providers == providers
other.providers.zip(providers).all { (another, myProvider) ->
myProvider.isTheSameAs(another) override fun hashCode(): Int = providers.hashCode()
}
override fun ownerClassId(): ClassId? = null override fun ownerClassId(): ClassId? = null
} }
@@ -13,6 +13,5 @@ internal object EmptyAnnotationsProvider : AnnotationsProvider {
override fun annotationInfos(): List<KtAnnotationApplicationInfo> = emptyList() override fun annotationInfos(): List<KtAnnotationApplicationInfo> = emptyList()
override fun get(classId: ClassId): Collection<KtAnnotationApplicationWithArgumentsInfo> = emptyList() override fun get(classId: ClassId): Collection<KtAnnotationApplicationWithArgumentsInfo> = emptyList()
override fun contains(classId: ClassId): Boolean = false override fun contains(classId: ClassId): Boolean = false
override fun isTheSameAs(other: Any?): Boolean = this === other
override fun ownerClassId(): ClassId? = null override fun ownerClassId(): ClassId? = null
} }
@@ -36,12 +36,14 @@ internal class SymbolAnnotationsProvider<T : KtAnnotatedSymbol>(
annotatedSymbol.hasAnnotation(classId, annotationUseSiteTargetFilter) annotatedSymbol.hasAnnotation(classId, annotationUseSiteTargetFilter)
} }
override fun isTheSameAs(other: Any?): Boolean = other === this || override fun equals(other: Any?): Boolean = other === this ||
other is SymbolAnnotationsProvider<*> && other is SymbolAnnotationsProvider<*> &&
other.ktModule == ktModule && other.ktModule == ktModule &&
other.annotationUseSiteTargetFilter == annotationUseSiteTargetFilter && other.annotationUseSiteTargetFilter == annotationUseSiteTargetFilter &&
annotatedSymbolPointer.pointsToTheSameSymbolAs(other.annotatedSymbolPointer) annotatedSymbolPointer.pointsToTheSameSymbolAs(other.annotatedSymbolPointer)
override fun hashCode(): Int = annotatedSymbolPointer.hashCode()
override fun ownerClassId(): ClassId? = withAnnotatedSymbol { annotatedSymbol -> override fun ownerClassId(): ClassId? = withAnnotatedSymbol { annotatedSymbol ->
(annotatedSymbol as? KtClassLikeSymbol)?.classIdIfNonLocal (annotatedSymbol as? KtClassLikeSymbol)?.classIdIfNonLocal
} }
@@ -55,7 +55,7 @@ internal class SymbolLightLazyAnnotation(
other.annotationApplication.index == annotationApplication.index && other.annotationApplication.index == annotationApplication.index &&
other.annotationApplication.useSiteTarget == annotationApplication.useSiteTarget && other.annotationApplication.useSiteTarget == annotationApplication.useSiteTarget &&
other.annotationApplication.isCallWithArguments == annotationApplication.isCallWithArguments && other.annotationApplication.isCallWithArguments == annotationApplication.isCallWithArguments &&
annotationsProvider.isTheSameAs(other.annotationsProvider) && other.annotationsProvider == annotationsProvider &&
other.parent == parent other.parent == parent
override fun hashCode(): Int = fqName.hashCode() override fun hashCode(): Int = fqName.hashCode()