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
@@ -44,7 +44,7 @@ interface IrBuilderExtension {
private fun IrClass.declareSimpleFunctionWithExternalOverrides(descriptor: FunctionDescriptor): IrSimpleFunction {
return compilerContext.symbolTable.declareSimpleFunction(startOffset, endOffset, SERIALIZABLE_PLUGIN_ORIGIN, descriptor)
.also { f ->
descriptor.overriddenDescriptors.mapTo(f.overriddenSymbols) {
f.overriddenSymbols = descriptor.overriddenDescriptors.map {
compilerContext.symbolTable.referenceSimpleFunction(it.original)
}
}
@@ -357,16 +357,15 @@ interface IrBuilderExtension {
if (!overwriteValueParameters)
assert(valueParameters.isEmpty())
else
valueParameters.clear()
valueParameters.addAll(descriptor.valueParameters.map { it.irValueParameter() })
valueParameters = descriptor.valueParameters.map { it.irValueParameter() }
assert(typeParameters.isEmpty())
if (copyTypeParameters) copyTypeParamsFromDescriptor()
}
fun IrFunction.copyTypeParamsFromDescriptor() {
descriptor.typeParameters.mapTo(typeParameters) {
typeParameters += descriptor.typeParameters.map {
IrTypeParameterImpl(
startOffset, endOffset,
SERIALIZABLE_PLUGIN_ORIGIN,
@@ -76,7 +76,7 @@ class SerializableCompanionIrGenerator(
)
}
irSerializableClass.annotations.add(annotationCtorCall)
irSerializableClass.annotations += annotationCtorCall
}
override fun generateSerializerGetter(methodDescriptor: FunctionDescriptor) {