KtLightMethod(Field): do not use clsDelegate in hashCode && equality checks
This commit is contained in:
+4
-11
@@ -102,18 +102,11 @@ sealed class KtLightFieldImpl<T: PsiField>(
|
|||||||
override fun toString(): String = "${this::class.java.simpleName}:$name"
|
override fun toString(): String = "${this::class.java.simpleName}:$name"
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean =
|
override fun equals(other: Any?): Boolean =
|
||||||
other is KtLightField &&
|
other is KtLightFieldImpl<*> &&
|
||||||
name == other.name &&
|
this.name == other.name &&
|
||||||
lightMemberOrigin == other.lightMemberOrigin &&
|
this.containingClass == other.containingClass
|
||||||
containingClass == other.containingClass &&
|
|
||||||
clsDelegate == other.clsDelegate
|
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode() = 31 * containingClass.hashCode() + (name?.hashCode() ?: 0)
|
||||||
var result = lightMemberOrigin?.hashCode() ?: 0
|
|
||||||
result = 31 * result + clsDelegate.hashCode()
|
|
||||||
result = 31 * result + containingClass.hashCode()
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
override val kotlinOrigin: KtDeclaration? get() = lightMemberOrigin?.originalElement
|
override val kotlinOrigin: KtDeclaration? get() = lightMemberOrigin?.originalElement
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ import com.intellij.psi.scope.PsiScopeProcessor
|
|||||||
import com.intellij.psi.util.*
|
import com.intellij.psi.util.*
|
||||||
import com.intellij.util.IncorrectOperationException
|
import com.intellij.util.IncorrectOperationException
|
||||||
import org.jetbrains.kotlin.asJava.LightClassUtil
|
import org.jetbrains.kotlin.asJava.LightClassUtil
|
||||||
import org.jetbrains.kotlin.asJava.builder.ClsWrapperStubPsiFactory
|
import org.jetbrains.kotlin.asJava.builder.*
|
||||||
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
|
|
||||||
import org.jetbrains.kotlin.asJava.builder.LightMemberOriginForDeclaration
|
|
||||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||||
import org.jetbrains.kotlin.asJava.propertyNameByAccessor
|
import org.jetbrains.kotlin.asJava.propertyNameByAccessor
|
||||||
import org.jetbrains.kotlin.asJava.unwrapped
|
import org.jetbrains.kotlin.asJava.unwrapped
|
||||||
@@ -188,14 +186,21 @@ class KtLightMethodImpl private constructor(
|
|||||||
return super.isEquivalentTo(another)
|
return super.isEquivalentTo(another)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean =
|
private val _memberIndex: MemberIndex?
|
||||||
other is KtLightMethod &&
|
get() = (dummyDelegate ?: clsDelegate).memberIndex
|
||||||
name == other.name &&
|
|
||||||
lightMethodOrigin == other.lightMethodOrigin &&
|
|
||||||
containingClass == other.containingClass &&
|
|
||||||
clsDelegate == other.clsDelegate
|
|
||||||
|
|
||||||
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMethodOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + clsDelegate.hashCode()
|
/* comparing origin and member index should be enough to determine equality:
|
||||||
|
for compiled elements origin contains delegate
|
||||||
|
for source elements index is unique to each member
|
||||||
|
*/
|
||||||
|
override fun equals(other: Any?): Boolean =
|
||||||
|
other is KtLightMethodImpl &&
|
||||||
|
this.name == other.name &&
|
||||||
|
this.containingClass == other.containingClass &&
|
||||||
|
this.lightMethodOrigin == other.lightMethodOrigin &&
|
||||||
|
this._memberIndex == other._memberIndex
|
||||||
|
|
||||||
|
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMethodOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + (_memberIndex?.hashCode() ?: 0)
|
||||||
|
|
||||||
override fun toString(): String = "${this::class.java.simpleName}:$name"
|
override fun toString(): String = "${this::class.java.simpleName}:$name"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user