From f06e116bf7755bd8f7bcdf43410549518ee4d1c0 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Tue, 23 Jun 2020 17:29:52 +0300 Subject: [PATCH] Improved equals for light decompiled declarations --- .../KtLightClassForDecompiledDeclaration.kt | 2 +- .../KtLightFieldForDecompiledDeclaration.kt | 7 +++++-- .../KtLightMethodForDecompiledDeclaration.kt | 9 +++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightClassForDecompiledDeclaration.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightClassForDecompiledDeclaration.kt index 58f3f7bb25f..04803f5f3f0 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightClassForDecompiledDeclaration.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightClassForDecompiledDeclaration.kt @@ -219,7 +219,7 @@ open class KtLightClassForDecompiledDeclaration( qualifiedName == other.qualifiedName && kotlinOrigin?.fqName == other.kotlinOrigin?.fqName - override fun hashCode(): Int = clsDelegate.hashCode() + override fun hashCode(): Int = qualifiedName?.hashCode() ?: kotlinOrigin?.fqName?.hashCode() ?: 0 override fun copy(): PsiElement = this diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightFieldForDecompiledDeclaration.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightFieldForDecompiledDeclaration.kt index 58980801dbf..ecd41b11f81 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightFieldForDecompiledDeclaration.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightFieldForDecompiledDeclaration.kt @@ -57,9 +57,12 @@ open class KtLightFieldForDecompiledDeclaration( override fun computeConstantValue(visitedVars: MutableSet?): Any? = (fldDelegate as? PsiVariableEx)?.computeConstantValue(visitedVars) - override fun equals(other: Any?): Boolean = other is KtLightFieldForDecompiledDeclaration && fldParent == other.fldParent && fldDelegate == other.fldDelegate + override fun equals(other: Any?): Boolean = other is KtLightFieldForDecompiledDeclaration && + name == other.name && + fldParent == other.fldParent && + fldDelegate == other.fldDelegate - override fun hashCode(): Int = fldDelegate.hashCode() + override fun hashCode(): Int = name.hashCode() override fun copy(): PsiElement = this diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightMethodForDecompiledDeclaration.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightMethodForDecompiledDeclaration.kt index 5acbebcaac0..498aea08685 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightMethodForDecompiledDeclaration.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/caches/lightClasses/decompiledDeclarations/KtLightMethodForDecompiledDeclaration.kt @@ -15,8 +15,6 @@ import org.jetbrains.kotlin.asJava.classes.KtLightClass import org.jetbrains.kotlin.asJava.elements.KtLightElementBase import org.jetbrains.kotlin.asJava.elements.KtLightMember import org.jetbrains.kotlin.asJava.elements.KtLightMethod -import org.jetbrains.kotlin.asJava.propertyNameByAccessor -import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper import org.jetbrains.kotlin.idea.caches.lightClasses.LightMemberOriginForCompiledMethod import org.jetbrains.kotlin.psi.KtDeclaration @@ -88,9 +86,12 @@ class KtLightMethodForDecompiledDeclaration( override fun getSignature(substitutor: PsiSubstitutor): MethodSignature = MethodSignatureBackedByPsiMethod.create(this, substitutor) - override fun equals(other: Any?): Boolean = other is KtLightMethodForDecompiledDeclaration && funParent == other.funParent && funDelegate == other.funDelegate + override fun equals(other: Any?): Boolean = other is KtLightMethodForDecompiledDeclaration && + name == other.name && + funParent == other.funParent && + funDelegate == other.funDelegate - override fun hashCode(): Int = funDelegate.hashCode() + override fun hashCode(): Int = name.hashCode() override fun copy(): PsiElement = this