diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt index b5c37483310..d318faa5ca2 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/AbstractFir2IrLazyFunction.kt @@ -91,6 +91,7 @@ abstract class AbstractFir2IrLazyFunction( override var correspondingPropertySymbol: IrPropertySymbol? = null override var attributeOwnerId: IrAttributeContainer = this + override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null override var metadata: MetadataSource? get() = null diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt index 0c88a9113e1..138114e9ad3 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyClass.kt @@ -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() diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt index 290aca5c2c4..a18dc431b40 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt @@ -235,4 +235,5 @@ class Fir2IrLazyProperty( get() = fir.containerSource override var attributeOwnerId: IrAttributeContainer = this + override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null } diff --git a/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/declarations/IrAttributeContainer.kt b/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/declarations/IrAttributeContainer.kt index 23d17615526..b1508c03515 100644 --- a/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/declarations/IrAttributeContainer.kt +++ b/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/declarations/IrAttributeContainer.kt @@ -16,4 +16,6 @@ import org.jetbrains.kotlin.ir.IrElement */ interface IrAttributeContainer : IrElement { var attributeOwnerId: IrAttributeContainer + + var attributeOwnerIdBeforeInline: IrAttributeContainer? } diff --git a/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/expressions/IrExpression.kt b/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/expressions/IrExpression.kt index 7697b220c62..e20a08be082 100644 --- a/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/expressions/IrExpression.kt +++ b/compiler/ir/ir.tree/gen/org/jetbrains/kotlin/ir/expressions/IrExpression.kt @@ -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 transform(transformer: IrElementTransformer, data: D): IrExpression diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarations.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarations.kt index d955ed2ae21..4872a81ae6d 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarations.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarations.kt @@ -17,6 +17,7 @@ import java.io.File fun D.copyAttributes(other: IrAttributeContainer?): D = apply { if (other != null) { attributeOwnerId = other.attributeOwnerId + attributeOwnerIdBeforeInline = other.attributeOwnerIdBeforeInline } } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt index 3cc96dcbbf2..eba8ded51d8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt @@ -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 = emptyList() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt index 100d1a1b778..26b5ec41405 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionImpl.kt @@ -64,6 +64,7 @@ abstract class IrFunctionCommonImpl( @Suppress("LeakingThis") override var attributeOwnerId: IrAttributeContainer = this + override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null override var correspondingPropertySymbol: IrPropertySymbol? = null } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyImpl.kt index c1077660325..33958bd5aaf 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyImpl.kt @@ -45,6 +45,7 @@ abstract class IrPropertyCommonImpl( override var metadata: MetadataSource? = null override var attributeOwnerId: IrAttributeContainer = this + override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null } class IrPropertyImpl( diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyClass.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyClass.kt index e4b6eca08cb..5ece1a317e3 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyClass.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyClass.kt @@ -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 diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt index 4644880e80e..5ff29c6b583 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyFunction.kt @@ -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? diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt index 9fb2bc3e2c9..1a968776874 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/lazy/IrLazyProperty.kt @@ -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.") } diff --git a/compiler/ir/ir.tree/tree-generator/src/org/jetbrains/kotlin/ir/generator/IrTree.kt b/compiler/ir/ir.tree/tree-generator/src/org/jetbrains/kotlin/ir/generator/IrTree.kt index 24d3dc0ee6a..40d9d387ec0 100644 --- a/compiler/ir/ir.tree/tree-generator/src/org/jetbrains/kotlin/ir/generator/IrTree.kt +++ b/compiler/ir/ir.tree/tree-generator/src/org/jetbrains/kotlin/ir/generator/IrTree.kt @@ -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) {