Add original KotlinType to rendered IrErrorType

Also improve an error message in `IrType.erasedUpperBound`, which seems
like a frequent first place where the JVM IR backend crashes in case an
error type has made it past psi2ir.

This will help in diagnosing problems such as KT-45016.
This commit is contained in:
Alexander Udalov
2021-03-01 20:28:27 +01:00
parent cd9463ae8d
commit e3dc112c5f
7 changed files with 60 additions and 59 deletions
@@ -113,7 +113,7 @@ val IrType.erasedUpperBound: IrClass
get() = when (val classifier = classifierOrNull) {
is IrClassSymbol -> classifier.owner
is IrTypeParameterSymbol -> classifier.owner.erasedUpperBound
else -> throw IllegalStateException()
else -> error(render())
}
/**
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.ReturnTypeIsNotInitializedException
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.types.Variance
@@ -103,7 +104,7 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false) : IrEl
when (this) {
is IrDynamicType -> "dynamic"
is IrErrorType -> "IrErrorType"
is IrErrorType -> "IrErrorType($originalKotlinType)"
is IrSimpleType -> buildTrimEnd {
append(classifier.renderClassifierFqn())