Provide equals/hashCode based on original PSI to avoid potential PCEs
#KT-59445
This commit is contained in:
committed by
Space Team
parent
05652e7d8d
commit
d0477a6a30
+9
@@ -15,10 +15,19 @@ internal class JavaElementPsiSourceWithSmartPointer<PSI : PsiElement>(
|
||||
override val factory: JavaElementSourceFactory,
|
||||
) : JavaElementPsiSource<PSI>() {
|
||||
|
||||
// is used only for the purposes of equals/hashCode to avoid underlying PCE
|
||||
private val originalPsi: PSI = psi
|
||||
|
||||
override val psi: PSI
|
||||
get() {
|
||||
return pointer.element
|
||||
?: error("Cannot restore a PsiElement from $pointer")
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other === this) true else other is JavaElementPsiSourceWithSmartPointer<*> && originalPsi == other.originalPsi
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = originalPsi.hashCode()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user