[FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull

#KT-59855 Fixed
This commit is contained in:
Kirill Rakhman
2023-08-04 10:43:25 +02:00
committed by Space Team
parent f60d81097c
commit 8d7c5b375e
76 changed files with 538 additions and 565 deletions
@@ -47,7 +47,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
private fun Stack.push(
levelName: String,
defaultValues: MutableList<String> = mutableListOf()
defaultValues: MutableList<String> = mutableListOf(),
) = this.add(levelName to defaultValues)
private fun Stack.pop() = this.removeAt(this.size - 1)
@@ -164,7 +164,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
if (function.isLocal) stack.addName(function.name ?: ANONYMOUS_NAME)
stack.push((function.name ?: ANONYMOUS_NAME))
if (function.equalsToken != null) {
function.bodyExpression!!.firstOfTypeWithRender<FirReturnExpression>(function.equalsToken) { this.result.typeRef }
function.bodyExpression!!.firstOfTypeWithRender<FirReturnExpression>(function.equalsToken) { this.result.coneType.toFirResolvedTypeRef() }
?: function.firstOfTypeWithRender<FirCallableDeclaration>(function.equalsToken) { this.returnTypeRef }
}
super.visitNamedFunction(function)
@@ -249,12 +249,12 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
}
override fun visitIfExpression(expression: KtIfExpression) {
expression.firstOfTypeWithRender<FirWhenExpression> { this.typeRef }
expression.firstOfTypeWithRender<FirWhenExpression> { this.coneType.toFirResolvedTypeRef() }
super.visitIfExpression(expression)
}
override fun visitWhenExpression(expression: KtWhenExpression) {
expression.firstOfTypeWithRender<FirWhenExpression> { this.typeRef }
expression.firstOfTypeWithRender<FirWhenExpression> { this.coneType.toFirResolvedTypeRef() }
super.visitWhenExpression(expression)
}
@@ -306,7 +306,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
}
override fun visitWhenEntry(ktWhenEntry: KtWhenEntry) {
ktWhenEntry.firstOfTypeWithRender<FirWhenBranch>(ktWhenEntry.expression) { this.result.typeRef }
ktWhenEntry.firstOfTypeWithRender<FirWhenBranch>(ktWhenEntry.expression) { this.result.coneType.toFirResolvedTypeRef() }
super.visitWhenEntry(ktWhenEntry)
}
@@ -564,7 +564,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
fir.receiverParameter?.accept(this, data)
data.append(".").append(callableName)
}
call.dispatchReceiver.typeRef.annotations.any { it.isExtensionFunctionAnnotationCall } -> {
call.dispatchReceiver.coneType.isExtensionFunctionType -> {
withExtensionFunctionType = true
fir.valueParameters.first().returnTypeRef.accept(this, data)
data.append(".").append(callableName)
@@ -786,7 +786,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
override fun <T> visitConstExpression(constExpression: FirConstExpression<T>, data: StringBuilder) {
when (constExpression.kind) {
ConstantValueKind.String -> return
ConstantValueKind.Null -> constExpression.typeRef.accept(this, data)
ConstantValueKind.Null -> constExpression.coneType.tryToRenderConeAsFunctionType(data)
else -> data.append(constExpression.kind)
}
}
@@ -796,7 +796,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
when {
fir is FirRegularClass && fir.classKind != ClassKind.ENUM_CLASS && fir.companionObjectSymbol?.defaultType() == resolvedQualifier.coneTypeSafe() -> {
data.append("companion object ")
data.append(resolvedQualifier.typeRef.render()).append(": ")
data.append(resolvedQualifier.coneType.toFirResolvedTypeRef().render()).append(": ")
data.append(fir.symbol.classId.asString().removeCurrentFilePackage())
}
fir is FirClass -> {