Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1008,36 +1008,28 @@ fun IrType.remapTypeParameters(
srcToDstParameterMap: Map<IrTypeParameter, IrTypeParameter>? = null
): IrType =
when (this) {
is IrSimpleType -> {
is IrSimpleType if (classifier.owner is IrTypeParameter || classifier.owner is IrClass) -> {
val classifier = classifier.owner
when {
classifier is IrTypeParameter -> {
val newClassifier =
srcToDstParameterMap?.get(classifier) ?: if (classifier.parent == source)
target.typeParameters[classifier.index]
else
classifier
IrSimpleTypeImpl(newClassifier.symbol, nullability, arguments, annotations)
}

classifier is IrClass ->
IrSimpleTypeImpl(
classifier.symbol,
nullability,
arguments.memoryOptimizedMap {
when (it) {
is IrTypeProjection -> makeTypeProjection(
it.type.remapTypeParameters(source, target, srcToDstParameterMap),
it.variance
)
is IrStarProjection -> it
}
},
annotations
)

else -> this
}
val newSymbol: IrClassifierSymbol = when (classifier) {
is IrTypeParameter if srcToDstParameterMap?.get(classifier) != null -> srcToDstParameterMap[classifier]!!.symbol
is IrTypeParameter if classifier.parent == source && target.typeParameters.size > classifier.index -> target.typeParameters[classifier.index].symbol
else -> classifier.symbol
} as IrClassifierSymbol

IrSimpleTypeImpl(
newSymbol,
nullability,
if (classifier is IrClass) arguments.memoryOptimizedMap {
when (it) {
is IrTypeProjection -> makeTypeProjection(
it.type.remapTypeParameters(source, target, srcToDstParameterMap),
it.variance
)
is IrStarProjection -> it
}
} else arguments,
annotations
)
}
else -> this
}
Expand Down