Add reference equality shortcut for equals() in light members

This commit is contained in:
Nikolay Krasko
2017-07-15 14:55:10 +03:00
parent 44ed903303
commit dfef1f4921
2 changed files with 10 additions and 8 deletions
@@ -60,9 +60,10 @@ sealed class KtLightFieldImpl<D : PsiField>(
}
override fun equals(other: Any?): Boolean =
other is KtLightFieldImpl<*> &&
this.name == other.name &&
this.containingClass == other.containingClass
this === other ||
(other is KtLightFieldImpl<*> &&
this.name == other.name &&
this.containingClass == other.containingClass)
override fun hashCode() = 31 * containingClass.hashCode() + name.hashCode()
@@ -147,11 +147,12 @@ class KtLightMethodImpl private constructor(
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.lightMemberOrigin == other.lightMemberOrigin &&
this._memberIndex == other._memberIndex
this === other ||
(other is KtLightMethodImpl &&
this.name == other.name &&
this.containingClass == other.containingClass &&
this.lightMemberOrigin == other.lightMemberOrigin &&
this._memberIndex == other._memberIndex)
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMemberOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + (_memberIndex?.hashCode() ?: 0)