AA FIR: have KtFirReceiverParameterSymbol implement KtFirSymbol

Aside from making the code shorter, this allows for correct equals/hashCode.
This commit is contained in:
Sonya Valchuk
2024-01-19 12:02:03 +00:00
committed by Space Cloud
parent 69c83698fb
commit eb23984182
@@ -27,10 +27,9 @@ import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
import org.jetbrains.kotlin.utils.exceptions.requireWithAttachment
internal class KtFirReceiverParameterSymbol(
val firSymbol: FirCallableSymbol<*>,
val analysisSession: KtFirAnalysisSession,
) : KtReceiverParameterSymbol(), KtLifetimeOwner {
override val token: KtLifetimeToken get() = analysisSession.token
override val firSymbol: FirCallableSymbol<*>,
override val analysisSession: KtFirAnalysisSession,
) : KtReceiverParameterSymbol(), KtFirSymbol<FirCallableSymbol<*>> {
override val psi: PsiElement? = withValidityAssertion{ firSymbol.fir.receiverParameter?.typeRef?.psi }
init {
@@ -40,15 +39,13 @@ internal class KtFirReceiverParameterSymbol(
}
override val type: KtType by cached {
firSymbol.receiverType(analysisSession.firSymbolBuilder)
firSymbol.receiverType(builder)
?: errorWithAttachment("${firSymbol::class} doesn't have an extension receiver") {
withFirEntry("callable", firSymbol.fir)
}
}
override val owningCallableSymbol: KtCallableSymbol by cached { analysisSession.firSymbolBuilder.callableBuilder.buildCallableSymbol(firSymbol) }
override val origin: KtSymbolOrigin = withValidityAssertion { firSymbol.fir.ktSymbolOrigin() }
override val owningCallableSymbol: KtCallableSymbol by cached { builder.callableBuilder.buildCallableSymbol(firSymbol) }
context(KtAnalysisSession)
override fun createPointer(): KtSymbolPointer<KtReceiverParameterSymbol> = withValidityAssertion {
@@ -56,6 +53,9 @@ internal class KtFirReceiverParameterSymbol(
}
override val annotationsList: KtAnnotationsList by cached {
KtFirAnnotationListForReceiverParameter.create(firSymbol, builder = analysisSession.firSymbolBuilder)
KtFirAnnotationListForReceiverParameter.create(firSymbol, builder)
}
override fun equals(other: Any?): Boolean = symbolEquals(other)
override fun hashCode(): Int = symbolHashCode()
}