[FIR] Rename FirExpression.coneType to resolvedType

This commit is contained in:
Kirill Rakhman
2023-08-21 17:50:23 +02:00
committed by Space Team
parent ab6d87a1a2
commit 7fde5af7f8
91 changed files with 364 additions and 342 deletions
@@ -421,7 +421,7 @@ internal class KtFirCallResolver(
val extensionReceiverValue: KtReceiverValue?
if (explicitReceiverKind == ExplicitReceiverKind.DISPATCH_RECEIVER) {
dispatchReceiverValue =
KtExplicitReceiverValue(explicitReceiverPsi, dispatchReceiver.coneType.asKtType(), false, token)
KtExplicitReceiverValue(explicitReceiverPsi, dispatchReceiver.resolvedType.asKtType(), false, token)
if (firstArgIsExtensionReceiver) {
extensionReceiverValue = (fir as FirFunctionCall).arguments.firstOrNull()?.toKtReceiverValue()
} else {
@@ -430,7 +430,7 @@ internal class KtFirCallResolver(
} else {
dispatchReceiverValue = dispatchReceiver.toKtReceiverValue()
extensionReceiverValue =
KtExplicitReceiverValue(explicitReceiverPsi, extensionReceiver.coneType.asKtType(), false, token)
KtExplicitReceiverValue(explicitReceiverPsi, extensionReceiver.resolvedType.asKtType(), false, token)
}
return KtPartiallyAppliedSymbol(
with(analysisSession) { unsubstitutedKtSignature.substitute(substitutor) },
@@ -777,12 +777,12 @@ internal class KtFirCallResolver(
(calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirNamedFunctionSymbol ?: return null
val substitutor = createConeSubstitutorFromTypeArguments() ?: return null
val dispatchReceiverValue = if (explicitReceiverPsiSupplement != null && explicitReceiver == dispatchReceiver) {
explicitReceiverPsiSupplement.toExplicitReceiverValue(dispatchReceiver.coneType.asKtType())
explicitReceiverPsiSupplement.toExplicitReceiverValue(dispatchReceiver.resolvedType.asKtType())
} else {
dispatchReceiver.toKtReceiverValue()
}
val extensionReceiverValue = if (explicitReceiverPsiSupplement != null && explicitReceiver == extensionReceiver) {
explicitReceiverPsiSupplement.toExplicitReceiverValue(extensionReceiver.coneType.asKtType())
explicitReceiverPsiSupplement.toExplicitReceiverValue(extensionReceiver.resolvedType.asKtType())
} else {
extensionReceiver.toKtReceiverValue()
}
@@ -811,12 +811,12 @@ internal class KtFirCallResolver(
?: return null
else -> return null
}
KtImplicitReceiverValue(implicitPartiallyAppliedSymbol, coneType.asKtType())
KtImplicitReceiverValue(implicitPartiallyAppliedSymbol, resolvedType.asKtType())
}
else -> {
val psi = psi
if (psi !is KtExpression) return null
psi.toExplicitReceiverValue(coneType.asKtType())
psi.toExplicitReceiverValue(resolvedType.asKtType())
}
}
}
@@ -1169,7 +1169,7 @@ internal class KtFirCallResolver(
val equalsSymbolInAny = equalsSymbolInAny
val leftOperand = arguments.firstOrNull() ?: return null
val session = analysisSession.useSiteSession
val leftOperandType = leftOperand.coneType
val leftOperandType = leftOperand.resolvedType
val classSymbol = leftOperandType.fullyExpandedType(session).toSymbol(session) as? FirClassSymbol<*>
val equalsSymbol = classSymbol?.getEqualsSymbol(equalsSymbolInAny) ?: equalsSymbolInAny
@@ -31,8 +31,8 @@ import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.utils.addToStdlib.applyIf
import org.jetbrains.kotlin.psi.psiUtil.getOutermostParenthesizerOrThis
import org.jetbrains.kotlin.utils.addToStdlib.applyIf
import org.jetbrains.kotlin.utils.exceptions.rethrowExceptionWithDetails
import org.jetbrains.kotlin.utils.exceptions.withPsiEntry
@@ -67,7 +67,7 @@ internal class KtFirExpressionTypeProvider(
}
private fun getKtExpressionType(expression: KtExpression, fir: FirElement): KtType? = when (fir) {
is FirFunctionCall -> getReturnTypeForArrayStyleAssignmentTarget(expression, fir) ?: fir.coneType.asKtType()
is FirFunctionCall -> getReturnTypeForArrayStyleAssignmentTarget(expression, fir) ?: fir.resolvedType.asKtType()
is FirPropertyAccessExpression -> {
// For unresolved `super`, we manually create an intersection type so that IDE features like completion can work correctly.
val containingClass = (fir.dispatchReceiver as? FirThisReceiverExpression)?.calleeReference?.boundSymbol as? FirClassSymbol<*>
@@ -80,19 +80,19 @@ internal class KtFirExpressionTypeProvider(
else -> ConeIntersectionType(superTypes).asKtType()
}
} else {
fir.coneType.asKtType()
fir.resolvedType.asKtType()
}
}
is FirVariableAssignment -> {
if (fir.lValue.source?.psi == expression) {
fir.lValue.coneType.asKtType()
fir.lValue.resolvedType.asKtType()
} else if (expression is KtUnaryExpression && expression.operationToken in KtTokens.INCREMENT_AND_DECREMENT) {
fir.rValue.coneType.asKtType()
fir.rValue.resolvedType.asKtType()
} else {
analysisSession.builtinTypes.UNIT
}
}
is FirExpression -> fir.coneType.asKtType()
is FirExpression -> fir.resolvedType.asKtType()
is FirNamedReference -> fir.getCorrespondingTypeIfPossible()?.asKtType()
is FirStatement -> with(analysisSession) { builtinTypes.UNIT }
is FirTypeRef, is FirImport, is FirPackageDirective, is FirLabel, is FirTypeParameterRef -> null
@@ -123,7 +123,7 @@ internal class KtFirExpressionTypeProvider(
* of the whole expression instead, and that is not what he wants.
*/
private fun FirNamedReference.getCorrespondingTypeIfPossible(): ConeKotlinType? =
findOuterPropertyAccessExpression()?.coneType
findOuterPropertyAccessExpression()?.resolvedType
/**
* Finds an outer expression for [this] named reference in cases when it is a part of a property access.
@@ -425,7 +425,7 @@ internal class KtFirExpressionTypeProvider(
private fun getDefiniteNullability(expression: KtExpression): DefiniteNullability {
fun FirExpression.isNotNullable() = with(analysisSession.useSiteSession.typeContext) {
!coneType.isNullableType()
!resolvedType.isNullableType()
}
when (val fir = expression.getOrBuildFir(analysisSession.firResolveSession)) {
@@ -36,23 +36,13 @@ import org.jetbrains.kotlin.fir.psi
import org.jetbrains.kotlin.fir.renderer.FirRenderer
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
import org.jetbrains.kotlin.fir.resolve.toSymbol
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.name.StandardClassIds
import org.jetbrains.kotlin.psi.KtAnnotationEntry
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtConstructorCalleeExpression
import org.jetbrains.kotlin.psi.KtDoubleColonExpression
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtTypeReference
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
import org.jetbrains.kotlin.types.model.CaptureStatus
import org.jetbrains.kotlin.util.bfs
@@ -172,9 +162,9 @@ internal class KtFirTypeProvider(
override fun getReceiverTypeForDoubleColonExpression(expression: KtDoubleColonExpression): KtType? {
return when (val fir = expression.getOrBuildFir(firResolveSession)) {
is FirGetClassCall ->
fir.coneType.getReceiverOfReflectionType()?.asKtType()
fir.resolvedType.getReceiverOfReflectionType()?.asKtType()
is FirCallableReferenceAccess ->
fir.coneType.getReceiverOfReflectionType()?.asKtType()
fir.resolvedType.getReceiverOfReflectionType()?.asKtType()
else -> throwUnexpectedFirElementError(fir, expression)
}
}
@@ -179,7 +179,7 @@ internal object FirAnnotationValueConverter {
val qualifierParts = mutableListOf<String?>()
fun process(expression: FirExpression) {
val errorType = expression.coneType as? ConeErrorType
val errorType = expression.resolvedType as? ConeErrorType
val unresolvedName = when (val diagnostic = errorType?.diagnostic) {
is ConeUnresolvedTypeQualifierError -> diagnostic.qualifier
is ConeUnresolvedNameError -> diagnostic.qualifier
@@ -261,7 +261,7 @@ internal object FirReferenceResolveHelper {
symbolBuilder: KtSymbolByFirBuilder
): Collection<KtSymbol> {
val lhs = expression.arguments.firstOrNull() ?: return emptyList()
val scope = lhs.coneType.scope(
val scope = lhs.resolvedType.scope(
session,
analysisSession.getScopeSessionFor(analysisSession.useSiteSession),
FakeOverrideTypeCalculator.DoNothing,