Add new filed attributeOwnerIdBeforeInline to IrAttributeContainer

This field is null by default, and it is set to current
`attributeOwnerId` when declaration was inlined and must be
generated with new name. In its turn `attributeOwnerId` must be set to
`this` to show that this is actually a new declaration, not a copy.
This commit is contained in:
Ivan Kylchik
2022-08-01 16:39:18 +02:00
committed by Space Team
parent 163ed20de5
commit 60702f0f02
13 changed files with 29 additions and 0 deletions
@@ -91,6 +91,7 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
override var correspondingPropertySymbol: IrPropertySymbol? = null
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
override var metadata: MetadataSource?
get() = null
@@ -72,6 +72,12 @@ class Fir2IrLazyClass(
get() = this
set(_) = mutationNotSupported()
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
get() = null
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var kind: ClassKind
get() = fir.classKind
set(_) = mutationNotSupported()
@@ -235,4 +235,5 @@ class Fir2IrLazyProperty(
get() = fir.containerSource
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
}
@@ -16,4 +16,6 @@ import org.jetbrains.kotlin.ir.IrElement
*/
interface IrAttributeContainer : IrElement {
var attributeOwnerId: IrAttributeContainer
var attributeOwnerIdBeforeInline: IrAttributeContainer?
}
@@ -22,6 +22,8 @@ abstract class IrExpression : IrElementBase(), IrStatement, IrVarargElement,
IrAttributeContainer {
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
abstract var type: IrType
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrExpression
@@ -17,6 +17,7 @@ import java.io.File
fun <D : IrAttributeContainer> D.copyAttributes(other: IrAttributeContainer?): D = apply {
if (other != null) {
attributeOwnerId = other.attributeOwnerId
attributeOwnerIdBeforeInline = other.attributeOwnerIdBeforeInline
}
}
@@ -57,6 +57,7 @@ open class IrClassImpl(
override var metadata: MetadataSource? = null
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
override var sealedSubclasses: List<IrClassSymbol> = emptyList()
}
@@ -64,6 +64,7 @@ abstract class IrFunctionCommonImpl(
@Suppress("LeakingThis")
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
override var correspondingPropertySymbol: IrPropertySymbol? = null
}
@@ -45,6 +45,7 @@ abstract class IrPropertyCommonImpl(
override var metadata: MetadataSource? = null
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
}
class IrPropertyImpl(
@@ -108,6 +108,7 @@ class IrLazyClass(
}
override var attributeOwnerId: IrAttributeContainer = this
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
val classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
@@ -104,6 +104,10 @@ class IrLazyFunction(
get() = this
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
get() = null
set(_) = error("We should never need to change attributeOwnerIdBeforeInline of external declarations.")
override var correspondingPropertySymbol: IrPropertySymbol? = null
override val containerSource: DeserializedContainerSource?
@@ -88,4 +88,8 @@ class IrLazyProperty(
override var attributeOwnerId: IrAttributeContainer
get() = this
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
get() = this
set(_) = error("We should never need to change attributeOwnerIdBeforeInline of external declarations.")
}
@@ -171,6 +171,7 @@ object IrTree : AbstractTreeBuilder() {
}
val attributeContainer: ElementConfig by element(Declaration) {
+field("attributeOwnerId", attributeContainer)
+field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) // null <=> this element wasn't inlined
}
val anonymousInitializer: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -496,6 +497,9 @@ object IrTree : AbstractTreeBuilder() {
+field("attributeOwnerId", attributeContainer) {
baseDefaultValue = code("this")
}
+field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) {
baseDefaultValue = code("null")
}
+field("type", irTypeType)
}
val statementContainer: ElementConfig by element(Expression) {