@@ -1008,40 +1008,33 @@ fun IrType.remapTypeParameters(
1008
1008
srcToDstParameterMap : Map <IrTypeParameter , IrTypeParameter >? = null
1009
1009
): IrType =
1010
1010
when (this ) {
1011
- is IrSimpleType -> {
1011
+ is IrSimpleType if (classifier.owner is IrTypeParameter || classifier.owner is IrClass ) -> {
1012
1012
val classifier = classifier.owner
1013
- when {
1014
- classifier is IrTypeParameter -> {
1015
- val newClassifier =
1016
- srcToDstParameterMap?.get(classifier) ? : if (classifier.parent == source)
1017
- target.typeParameters[classifier.index]
1018
- else
1019
- classifier
1020
- IrSimpleTypeImpl (newClassifier.symbol, nullability, arguments, annotations)
1021
- }
1022
-
1023
- classifier is IrClass ->
1024
- IrSimpleTypeImpl (
1025
- classifier.symbol,
1026
- nullability,
1027
- arguments.memoryOptimizedMap {
1028
- when (it) {
1029
- is IrTypeProjection -> makeTypeProjection(
1030
- it.type.remapTypeParameters(source, target, srcToDstParameterMap),
1031
- it.variance
1032
- )
1033
- is IrStarProjection -> it
1034
- }
1035
- },
1036
- annotations
1037
- )
1038
-
1039
- else -> this
1040
- }
1013
+ val newSymbol: IrClassifierSymbol = when (classifier) {
1014
+ is IrTypeParameter if srcToDstParameterMap?.get(classifier) != null -> srcToDstParameterMap[classifier]!! .symbol
1015
+ is IrTypeParameter if classifier.parent == source && target.typeParameters.size > classifier.index -> target.typeParameters[classifier.index].symbol
1016
+ else -> classifier.symbol
1017
+ } as IrClassifierSymbol
1018
+
1019
+ IrSimpleTypeImpl (
1020
+ newSymbol,
1021
+ nullability,
1022
+ if (classifier is IrClass ) arguments.memoryOptimizedMap {
1023
+ when (it) {
1024
+ is IrTypeProjection -> makeTypeProjection(
1025
+ it.type.remapTypeParameters(source, target, srcToDstParameterMap),
1026
+ it.variance
1027
+ )
1028
+ is IrStarProjection -> it
1029
+ }
1030
+ } else arguments,
1031
+ annotations
1032
+ )
1041
1033
}
1042
1034
else -> this
1043
1035
}
1044
1036
1037
+
1045
1038
fun IrDeclarationContainer.addChild (declaration : IrDeclaration ) {
1046
1039
this .declarations + = declaration
1047
1040
declaration.setDeclarationsParent(this )
0 commit comments