[FIR] Replace FirExpression.typeRef.coneType (and variants) with FirExpression.coneType

#KT-59855
This commit is contained in:
Kirill Rakhman
2023-07-31 17:36:01 +02:00
committed by Space Team
parent 1472b21993
commit 9ec814b7ad
108 changed files with 289 additions and 299 deletions
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector
import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirFunction
@@ -31,8 +30,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.coneTypeSafe
import org.jetbrains.kotlin.fir.types.coneTypeOrNull
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid
import org.jetbrains.kotlin.name.FqNameUnsafe
import org.jetbrains.kotlin.test.KotlinTestUtils
@@ -183,13 +181,13 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
): KtDiagnosticWithParameters1<String>? =
DebugInfoDiagnosticFactory1.EXPRESSION_TYPE.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) {
element.typeRef.renderAsString((element as? FirSmartCastExpression)?.originalExpression?.typeRef)
element.coneTypeOrNull.renderAsString((element as? FirSmartCastExpression)?.originalExpression?.coneTypeOrNull)
}
private fun FirTypeRef.renderAsString(originalTypeRef: FirTypeRef?): String {
val type = coneTypeSafe<ConeKotlinType>() ?: return "Type is unknown"
private fun ConeKotlinType?.renderAsString(originalType: ConeKotlinType?): String {
val type = this ?: return "Type is unknown"
val rendered = type.renderForDebugInfo()
val originalTypeRendered = originalTypeRef?.coneTypeSafe<ConeKotlinType>()?.renderForDebugInfo() ?: return rendered
val originalTypeRendered = originalType?.renderForDebugInfo() ?: return rendered
return "$rendered & $originalTypeRendered"
}
@@ -274,16 +274,13 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
}
override fun visitFunctionCall(functionCall: FirFunctionCall) {
val typeRef = functionCall.typeRef
val callee = functionCall.calleeReference
if (typeRef is FirResolvedTypeRef) {
val type = typeRef.type
if (type is ConeErrorType) {
errorFunctionCallTypes++
val psi = callee.psi
if (callee.isError() && psi != null) {
reportProblem(callee.diagnostic.reason, psi)
}
val type = functionCall.coneTypeOrNull
if (type is ConeErrorType) {
errorFunctionCallTypes++
val psi = callee.psi
if (callee.isError() && psi != null) {
reportProblem(callee.diagnostic.reason, psi)
}
}
@@ -291,16 +288,13 @@ class FirResolveBench(val withProgress: Boolean, val listener: BenchListener? =
}
override fun visitQualifiedAccessExpression(qualifiedAccessExpression: FirQualifiedAccessExpression) {
val typeRef = qualifiedAccessExpression.typeRef
val callee = qualifiedAccessExpression.calleeReference
if (typeRef is FirResolvedTypeRef) {
val type = typeRef.type
if (type is ConeErrorType) {
errorQualifiedAccessTypes++
val psi = callee.psi
if (callee.isError() && psi != null) {
reportProblem(callee.diagnostic.reason, psi)
}
val type = qualifiedAccessExpression.coneTypeOrNull
if (type is ConeErrorType) {
errorQualifiedAccessTypes++
val psi = callee.psi
if (callee.isError() && psi != null) {
reportProblem(callee.diagnostic.reason, psi)
}
}