Analysis API: do not consider ValidityToken when comparing symbols and types

Symbols with the same FirDeclaration may come from the different analysis sessions
This commit is contained in:
Ilya Kirillov
2021-09-23 10:32:47 +02:00
parent d63c136854
commit 55e6df6920
4 changed files with 6 additions and 8 deletions
@@ -139,8 +139,8 @@ internal class KtFirScopeProvider(
project, project,
builder, builder,
token, token,
analysisSession.searchScope, GlobalSearchScope.allScope(project), // TODO
analysisSession.targetPlatform analysisSession.targetPlatform,
) )
} }
} }
@@ -26,11 +26,10 @@ internal interface KtFirSymbol<out F : FirDeclaration> : KtSymbol, ValidityToken
internal fun KtFirSymbol<*>.symbolEquals(other: Any?): Boolean { internal fun KtFirSymbol<*>.symbolEquals(other: Any?): Boolean {
if (other !is KtFirSymbol<*>) return false if (other !is KtFirSymbol<*>) return false
if (this.token != other.token) return false
return this.firRef == other.firRef return this.firRef == other.firRef
} }
internal fun KtFirSymbol<*>.symbolHashCode(): Int = firRef.hashCode() * 31 + token.hashCode() internal fun KtFirSymbol<*>.symbolHashCode(): Int = firRef.hashCode()
internal tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (origin) { internal tailrec fun FirDeclaration.ktSymbolOrigin(): KtSymbolOrigin = when (origin) {
FirDeclarationOrigin.Source -> { FirDeclarationOrigin.Source -> {
@@ -30,11 +30,10 @@ internal interface KtFirType : ValidityTokenOwner {
private fun KtFirType.typeEquals(other: Any?): Boolean { private fun KtFirType.typeEquals(other: Any?): Boolean {
if (other !is KtFirType) return false if (other !is KtFirType) return false
if (this.token != other.token) return false
return this.coneType == other.coneType return this.coneType == other.coneType
} }
private fun KtFirType.typeHashcode(): Int = token.hashCode() * 31 + coneType.hashCode() private fun KtFirType.typeHashcode(): Int = coneType.hashCode()
internal class KtFirUsualClassType( internal class KtFirUsualClassType(
override val coneType: ConeClassLikeTypeImpl, override val coneType: ConeClassLikeTypeImpl,
@@ -47,9 +47,9 @@ class KtAnalysisSessionFe10BindingHolder private constructor(
companion object { companion object {
@InvalidWayOfUsingAnalysisSession @InvalidWayOfUsingAnalysisSession
fun create(firResolveState: FirModuleResolveState, token: ValidityToken, ktElement: KtElement): KtAnalysisSessionFe10BindingHolder { fun create(firResolveState: FirModuleResolveState, token: ValidityToken, @Suppress("UNUSED_PARAMETER") ktElement: KtElement): KtAnalysisSessionFe10BindingHolder {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
val firAnalysisSession = KtFirAnalysisSession.createAnalysisSessionByResolveState(firResolveState, token, ktElement) val firAnalysisSession = KtFirAnalysisSession.createAnalysisSessionByResolveState(firResolveState, token)
return KtAnalysisSessionFe10BindingHolder(firAnalysisSession) return KtAnalysisSessionFe10BindingHolder(firAnalysisSession)
} }
} }