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 import org.jetbrains.kotlin.utils.exceptions.requireWithAttachment
internal class KtFirReceiverParameterSymbol( internal class KtFirReceiverParameterSymbol(
val firSymbol: FirCallableSymbol<*>, override val firSymbol: FirCallableSymbol<*>,
val analysisSession: KtFirAnalysisSession, override val analysisSession: KtFirAnalysisSession,
) : KtReceiverParameterSymbol(), KtLifetimeOwner { ) : KtReceiverParameterSymbol(), KtFirSymbol<FirCallableSymbol<*>> {
override val token: KtLifetimeToken get() = analysisSession.token
override val psi: PsiElement? = withValidityAssertion{ firSymbol.fir.receiverParameter?.typeRef?.psi } override val psi: PsiElement? = withValidityAssertion{ firSymbol.fir.receiverParameter?.typeRef?.psi }
init { init {
@@ -40,15 +39,13 @@ internal class KtFirReceiverParameterSymbol(
} }
override val type: KtType by cached { override val type: KtType by cached {
firSymbol.receiverType(analysisSession.firSymbolBuilder) firSymbol.receiverType(builder)
?: errorWithAttachment("${firSymbol::class} doesn't have an extension receiver") { ?: errorWithAttachment("${firSymbol::class} doesn't have an extension receiver") {
withFirEntry("callable", firSymbol.fir) withFirEntry("callable", firSymbol.fir)
} }
} }
override val owningCallableSymbol: KtCallableSymbol by cached { analysisSession.firSymbolBuilder.callableBuilder.buildCallableSymbol(firSymbol) } override val owningCallableSymbol: KtCallableSymbol by cached { builder.callableBuilder.buildCallableSymbol(firSymbol) }
override val origin: KtSymbolOrigin = withValidityAssertion { firSymbol.fir.ktSymbolOrigin() }
context(KtAnalysisSession) context(KtAnalysisSession)
override fun createPointer(): KtSymbolPointer<KtReceiverParameterSymbol> = withValidityAssertion { override fun createPointer(): KtSymbolPointer<KtReceiverParameterSymbol> = withValidityAssertion {
@@ -56,6 +53,9 @@ internal class KtFirReceiverParameterSymbol(
} }
override val annotationsList: KtAnnotationsList by cached { 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()
} }