IR: make IrField.type mutable

This commit is contained in:
Georgy Bronnikov
2020-09-03 15:07:55 +03:00
parent 5065b1a4c6
commit d9681e535d
4 changed files with 17 additions and 3 deletions
@@ -33,7 +33,7 @@ class IrFieldImpl(
override var origin: IrDeclarationOrigin,
override val symbol: IrFieldSymbol,
override val name: Name,
override val type: IrType,
override var type: IrType,
override var visibility: DescriptorVisibility,
override val isFinal: Boolean,
override val isExternal: Boolean,
@@ -35,7 +35,7 @@ internal class PersistentIrField(
origin: IrDeclarationOrigin,
override val symbol: IrFieldSymbol,
override val name: Name,
override val type: IrType,
type: IrType,
override var visibility: DescriptorVisibility,
override val isFinal: Boolean,
override val isExternal: Boolean,
@@ -94,4 +94,14 @@ internal class PersistentIrField(
setCarrier().metadataField = v
}
}
override var typeField: IrType = type
override var type: IrType
get() = getCarrier().typeField
set(v) {
if (type !== v) {
setCarrier().typeField = v
}
}
}
@@ -11,8 +11,10 @@ import org.jetbrains.kotlin.ir.declarations.MetadataSource
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import org.jetbrains.kotlin.ir.types.IrType
internal interface FieldCarrier : DeclarationCarrier {
var typeField: IrType
var initializerField: IrExpressionBody?
var correspondingPropertySymbolField: IrPropertySymbol?
var metadataField: MetadataSource?
@@ -23,6 +25,7 @@ internal interface FieldCarrier : DeclarationCarrier {
parentField,
originField,
annotationsField,
typeField,
initializerField,
correspondingPropertySymbolField,
metadataField
@@ -35,6 +38,7 @@ internal class FieldCarrierImpl(
override var parentField: IrDeclarationParent?,
override var originField: IrDeclarationOrigin,
override var annotationsField: List<IrConstructorCall>,
override var typeField: IrType,
override var initializerField: IrExpressionBody?,
override var correspondingPropertySymbolField: IrPropertySymbol?,
override var metadataField: MetadataSource?
@@ -22,7 +22,7 @@ abstract class IrField :
@ObsoleteDescriptorBasedAPI
abstract override val descriptor: PropertyDescriptor
abstract val type: IrType
abstract var type: IrType
abstract val isFinal: Boolean
abstract val isExternal: Boolean
abstract val isStatic: Boolean