Kapt: Do not use PsiType comparison in equals() where possible

(cherry picked from commit 89ba634)
This commit is contained in:
Yan Zhulanow
2016-08-30 16:19:44 +03:00
committed by Yan Zhulanow
parent 18068c699d
commit cacec67044
5 changed files with 21 additions and 11 deletions
@@ -32,8 +32,8 @@ class JeArrayType(override val psiType: PsiArrayType, override val psiManager: P
override fun equals(other: Any?): Boolean{
if (this === other) return true
if (other?.javaClass != javaClass) return false
return psiType == (other as? JeArrayType)?.psiType
return componentType == (other as? JeArrayType)?.componentType
}
override fun hashCode() = psiType.hashCode()
override fun hashCode() = componentType.hashCode()
}
@@ -45,7 +45,8 @@ class JeClassInitializerExecutableTypeMirror(val initializer: PsiClassInitialize
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
return initializer == (other as JeClassInitializerExecutableTypeMirror).initializer
other as? JeClassInitializerExecutableTypeMirror ?: return false
return initializer == other.initializer
}
override fun hashCode() = initializer.hashCode()
@@ -80,13 +80,22 @@ class JeDeclaredType(
return PsiTypesUtil.getClassType(psiClass).toJeType(psiManager)
}
override fun equals(other: Any?): Boolean{
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
return psiType == (other as? JeDeclaredType)?.psiType
other as? JeDeclaredType ?: return false
return enclosingType == other.enclosingType
&& psiClass == other.psiClass
&& typeArguments == other.typeArguments
}
override fun hashCode(): Int {
var result = enclosingType.hashCode()
result = 31 * result + psiClass.hashCode()
result = 31 * result + typeArguments.hashCode()
return result
}
override fun hashCode() = psiType.hashCode()
override fun toString() = psiType.getCanonicalText(false)
}
@@ -31,11 +31,11 @@ class JeIntersectionType(
override fun getBounds() = psiType.superTypes.map { it.toJeType(psiManager) }
override fun equals(other: Any?): Boolean{
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
return psiType == (other as? JeIntersectionType)?.psiType
return bounds == (other as? JeIntersectionType)?.bounds
}
override fun hashCode() = psiType.hashCode()
override fun hashCode() = bounds.hashCode()
}
@@ -71,7 +71,7 @@ class JeMethodExecutableTypeMirror(
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other?.javaClass != javaClass) return false
return psi == (other as JeMethodExecutableTypeMirror).psi
return psi == (other as? JeMethodExecutableTypeMirror)?.psi
}
override fun hashCode() = psi.hashCode()