diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt index 59e52ff08c5..5f4463887ca 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/types/IrTypeSystemContext.kt @@ -140,8 +140,13 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon override fun TypeArgumentMarker.getVariance(): TypeVariance = (this as? IrTypeProjection)?.variance?.convertVariance() ?: TypeVariance.OUT - override fun TypeArgumentMarker.replaceType(newType: KotlinTypeMarker): TypeArgumentMarker = - IrTypeProjectionImpl(newType as IrType, (this as IrTypeProjection).variance) + override fun TypeArgumentMarker.replaceType(newType: KotlinTypeMarker): TypeArgumentMarker { + require(this is IrTypeArgument) + return when (this) { + is IrStarProjection -> this + is IrTypeProjection -> IrTypeProjectionImpl(newType as IrType, this.variance) + } + } override fun TypeArgumentMarker.getType() = (this as IrTypeProjection).type