[Analysis API] Add type to KtReceiverValue

Maybe in the future we could remove type from the
KtImplicitReceiverValue, because it has ktSymbol, and in theory
that should be enough to create corresponding KtType.
Unfortunately that is not the case for KtClassOrObjectSymbol --
it doesn't have the API for "default" type creation currently.

Regarding code in KtFirCallResolver.kt -- it seems like code there
needs some love in the future. Psi created via custom code there,
because for call x() FIR has receiver x with psi = null
This commit is contained in:
Stanislav Erokhin
2022-06-14 12:10:54 +02:00
committed by teamcity
parent 409d959816
commit 8d8fc6e291
131 changed files with 216 additions and 28 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.api.calls.KtCompoundAccess
import org.jetbrains.kotlin.analysis.api.calls.KtExplicitReceiverValue
import org.jetbrains.kotlin.analysis.api.components.KtCallResolver
import org.jetbrains.kotlin.analysis.api.impl.barebone.parentOfType
import org.jetbrains.kotlin.analysis.api.types.KtType
import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -36,8 +37,8 @@ abstract class AbstractKtCallResolver : KtCallResolver() {
return incOrDecOperationKind
}
protected fun KtExpression.toExplicitReceiverValue(): KtExplicitReceiverValue =
KtExplicitReceiverValue(this, isReceiverOfKtSafeQualifiedExpression(), token)
protected fun KtExpression.toExplicitReceiverValue(type: KtType): KtExplicitReceiverValue =
KtExplicitReceiverValue(this, type, isReceiverOfKtSafeQualifiedExpression(), token)
private fun KtExpression.isReceiverOfKtSafeQualifiedExpression(): Boolean {
val safeQualifiedExpression = parentOfType<KtSafeQualifiedExpression>() ?: return false