Uast: UastFakeLightMethod equality fix (KT-37200)

This commit is contained in:
Nicolay Mitropolsky
2020-03-06 14:12:23 +03:00
parent c1f89159d9
commit 753d4b3cbd
3 changed files with 37 additions and 0 deletions
@@ -185,6 +185,23 @@ private class UastFakeLightMethod(private val original: KtFunction, containingCl
}
override fun getParent(): PsiElement? = containingClass
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as UastFakeLightMethod
if (original != other.original) return false
return true
}
override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + original.hashCode()
return result
}
}
class KotlinUMethodWithFakeLightDelegate(val original: KtFunction, containingLightClass: PsiClass, givenParent: UElement?) :
@@ -188,6 +188,23 @@ private class UastFakeLightMethod(private val original: KtFunction, containingCl
}
override fun getParent(): PsiElement? = containingClass
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as UastFakeLightMethod
if (original != other.original) return false
return true
}
override fun hashCode(): Int {
var result = super.hashCode()
result = 31 * result + original.hashCode()
return result
}
}
class KotlinUMethodWithFakeLightDelegate(val original: KtFunction, containingLightClass: PsiClass, givenParent: UElement?) :
@@ -638,6 +638,9 @@ class KotlinUastApiTest : AbstractKotlinUastTest() {
function10 -> PsiType:T
function11 -> PsiType:T
""".trimIndent(), methods.joinToString("\n") { m -> m.name + " -> " + m.returnType.toString() })
for (method in methods.drop(3)) {
assertEquals("assert return types comparable for '${method.name}'", method.returnType, method.returnType)
}
}
}