Handle type arguments in IrType.eraseTypeParameters
This commit is contained in:
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrStarProjectionImpl
|
||||
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities
|
||||
@@ -51,7 +52,12 @@ fun IrType.eraseTypeParameters() = when (this) {
|
||||
is IrErrorType -> this
|
||||
is IrSimpleType ->
|
||||
when (val owner = classifier.owner) {
|
||||
is IrClass -> this
|
||||
is IrClass -> IrSimpleTypeImpl(
|
||||
classifier,
|
||||
hasQuestionMark,
|
||||
arguments.map { it.eraseTypeParameters() },
|
||||
annotations
|
||||
)
|
||||
is IrTypeParameter -> {
|
||||
val upperBound = owner.erasedUpperBound
|
||||
IrSimpleTypeImpl(
|
||||
@@ -66,6 +72,12 @@ fun IrType.eraseTypeParameters() = when (this) {
|
||||
else -> error("Unknown IrType kind: $this")
|
||||
}
|
||||
|
||||
fun IrTypeArgument.eraseTypeParameters(): IrTypeArgument = when (this) {
|
||||
is IrStarProjection -> this
|
||||
is IrTypeProjection -> makeTypeProjection(type.eraseTypeParameters(), variance)
|
||||
else -> error("Unknown IrTypeArgument kind: $this")
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the erased class for this type parameter according to the java erasure rules.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user