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
@@ -31,7 +31,7 @@ abstract class IrTypeParameter : IrDeclarationBase(), IrSymbolDeclaration<IrType
abstract val variance: Variance
abstract val index: Int
abstract val isReified: Boolean
abstract val superTypes: MutableList<IrType>
abstract var superTypes: List<IrType>
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitTypeParameter(this, data)
@@ -38,7 +38,7 @@ class IrLazyTypeParameter(
override var annotations: List<IrConstructorCall> by createLazyAnnotations()
override val superTypes: MutableList<IrType> by lazy {
override var superTypes: List<IrType> by lazyVar {
withInitialIr {
typeTranslator.buildWithScope(this.parent as IrTypeParametersContainer) {
val descriptor = symbol.descriptor
@@ -308,7 +308,7 @@ open class DeepCopyIrTreeWithSymbols(
override fun visitTypeParameter(declaration: IrTypeParameter): IrTypeParameter =
copyTypeParameter(declaration).apply {
// TODO type parameter scopes?
declaration.superTypes.mapTo(superTypes) { it.remapType() }
superTypes = declaration.superTypes.map { it.remapType() }
}
private fun copyTypeParameter(declaration: IrTypeParameter): IrTypeParameter =
@@ -331,7 +331,7 @@ open class DeepCopyIrTreeWithSymbols(
typeRemapper.withinScope(this) {
for ((thisTypeParameter, otherTypeParameter) in this.typeParameters.zip(other.typeParameters)) {
otherTypeParameter.superTypes.mapTo(thisTypeParameter.superTypes) {
thisTypeParameter.superTypes = otherTypeParameter.superTypes.map {
typeRemapper.remapType(it)
}
}