Improved equals for light decompiled declarations

This commit is contained in:
Igor Yakovlev
2020-06-23 17:29:52 +03:00
parent 27c139926c
commit f06e116bf7
3 changed files with 11 additions and 7 deletions
@@ -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
@@ -57,9 +57,12 @@ open class KtLightFieldForDecompiledDeclaration(
override fun computeConstantValue(visitedVars: MutableSet<PsiVariable>?): 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
@@ -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