IR API: change val ... : MutableList to var ...: List for most lists

All mutable state for IR declarations should be either:
- var (mutable properties)
- or class member list

Mutable properties are straightforward to persist.

The class member list is handled in a special way.
This commit is contained in:
Anton Bannykh
2020-01-14 14:12:51 +03:00
parent 0bcde9dffc
commit e8fba8bcb6
62 changed files with 203 additions and 200 deletions
@@ -908,7 +908,7 @@ abstract class IrFileDeserializer(
proto.coordinates.startOffset, proto.coordinates.endOffset,
deserializeIrDeclarationOrigin(proto.origin)
)
result.annotations.addAll(deserializeAnnotations(proto.annotationList))
result.annotations += deserializeAnnotations(proto.annotationList)
result.parent = parentsStack.peek()!!
return result
}
@@ -990,9 +990,9 @@ abstract class IrFileDeserializer(
thisReceiver = deserializeIrValueParameter(proto.thisReceiver)
proto.typeParameters.typeParameterList.mapTo(typeParameters) { deserializeIrTypeParameter(it) }
typeParameters = proto.typeParameters.typeParameterList.map { deserializeIrTypeParameter(it) }
proto.superTypeList.mapTo(superTypes) { deserializeIrType(it) }
superTypes = proto.superTypeList.map { deserializeIrType(it) }
(descriptor as? WrappedClassDescriptor)?.bind(this)
}
@@ -1011,7 +1011,7 @@ abstract class IrFileDeserializer(
origin
)
}.usingParent {
proto.typeParameters.typeParameterList.mapTo(typeParameters) {
typeParameters = proto.typeParameters.typeParameterList.map {
deserializeIrTypeParameter(it)
}
@@ -1024,8 +1024,8 @@ abstract class IrFileDeserializer(
block: (IrFunctionSymbol, Int, Int, IrDeclarationOrigin) -> T
) = withDeserializedIrDeclarationBase(proto.base) { symbol, startOffset, endOffset, origin ->
block(symbol as IrFunctionSymbol, startOffset, endOffset, origin).usingParent {
proto.typeParameters.typeParameterList.mapTo(typeParameters) { deserializeIrTypeParameter(it) }
proto.valueParameterList.mapTo(valueParameters) { deserializeIrValueParameter(it) }
typeParameters = proto.typeParameters.typeParameterList.map { deserializeIrTypeParameter(it) }
valueParameters = proto.valueParameterList.map { deserializeIrValueParameter(it) }
if (proto.hasDispatchReceiver())
dispatchReceiverParameter = deserializeIrValueParameter(proto.dispatchReceiver)
if (proto.hasExtensionReceiver())
@@ -1060,7 +1060,7 @@ abstract class IrFileDeserializer(
isOperator = proto.isOperator
)
}.apply {
proto.overriddenList.mapTo(overriddenSymbols) { deserializeIrSymbol(it) as IrSimpleFunctionSymbol }
overriddenSymbols = proto.overriddenList.map { deserializeIrSymbol(it) as IrSimpleFunctionSymbol }
(descriptor as? WrappedSimpleFunctionDescriptor)?.bind(this)
}
@@ -410,7 +410,7 @@ abstract class KotlinIrLinker(
fun deserializeFileImplicitDataIfFirstUse() {
annotations?.let {
file.annotations.addAll(deserializeAnnotations(it))
file.annotations += deserializeAnnotations(it)
annotations = null
}
}