IR: make IrTypeParameter.superTypes persistent mutable field

This commit is contained in:
Georgy Bronnikov
2020-09-08 09:45:10 +03:00
parent a409976d28
commit df1d9a0113
15 changed files with 32 additions and 20 deletions
@@ -224,8 +224,8 @@ private fun IrTypeParameter.copySuperTypesFrom(source: IrTypeParameter, srcToDst
val target = this
val sourceParent = source.parent as IrTypeParametersContainer
val targetParent = target.parent as IrTypeParametersContainer
source.superTypes.forEach {
target.superTypes.add(it.remapTypeParameters(sourceParent, targetParent, srcToDstParameterMap))
target.superTypes += source.superTypes.map {
it.remapTypeParameters(sourceParent, targetParent, srcToDstParameterMap)
}
}
@@ -526,7 +526,7 @@ fun IrFactory.createStaticFunctionWithReceivers(
fun remap(type: IrType): IrType =
type.remapTypeParameters(oldFunction, this, typeParameterMap)
typeParameters.forEach { it.superTypes.replaceAll { remap(it) } }
typeParameters.forEach { it.superTypes = it.superTypes.map(::remap) }
annotations = oldFunction.annotations
@@ -610,7 +610,7 @@ class LocalDeclarationsLowering(
newDeclaration.copyTypeParametersFrom(oldDeclaration, parameterMap = localFunctionContext.capturedTypeParameterToTypeParameter)
// Type parameters of oldDeclaration may depend on captured type parameters, so deal with that after copying.
newDeclaration.typeParameters.drop(newTypeParameters.size).forEach { tp ->
tp.superTypes.replaceAll { localFunctionContext.remapType(it) }
tp.superTypes = tp.superTypes.map { localFunctionContext.remapType(it) }
}
newDeclaration.parent = memberOwner
@@ -291,7 +291,7 @@ internal fun IrFactory.buildTypeParameter(builder: IrTypeParameterBuilder, paren
name, index, isReified, variance
).also {
wrappedDescriptor.bind(it)
it.superTypes.addAll(superTypes)
it.superTypes = superTypes
it.parent = parent
}
}