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 d318faa5ca2..a4054471ae0 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,7 +91,7 @@ abstract class AbstractFir2IrLazyFunction( override var correspondingPropertySymbol: IrPropertySymbol? = null override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: 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 138114e9ad3..e1ff476fe67 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,7 +72,7 @@ class Fir2IrLazyClass( get() = this set(_) = mutationNotSupported() - override var attributeOwnerIdBeforeInline: IrAttributeContainer? + override var originalBeforeInline: IrAttributeContainer? get() = null set(_) { error("Mutating Fir2Ir lazy elements is not possible") 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 a18dc431b40..60c2d5f880c 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,5 +235,5 @@ class Fir2IrLazyProperty( get() = fir.containerSource override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: IrAttributeContainer? = null } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt index 901791bf6f1..7282fd51b13 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InventNamesForLocalClasses.kt @@ -142,7 +142,7 @@ abstract class InventNamesForLocalClasses( } override fun visitFunctionReference(expression: IrFunctionReference, data: Data) { - if (data.processingInlinedFunction && expression.attributeOwnerIdBeforeInline == null) { + if (data.processingInlinedFunction && expression.originalBeforeInline == null) { // skip IrFunctionReference from `singleArgumentInlineFunction` return } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt index 9790c5803f0..1dccf4dc86a 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt @@ -141,7 +141,7 @@ class FunctionInlining( acceptVoid(object : IrElementVisitorVoid { private fun IrAttributeContainer.setUpCorrectAttributeOwner() { if (this.attributeOwnerId == this) return - this.attributeOwnerIdBeforeInline = this.attributeOwnerId + this.originalBeforeInline = this.attributeOwnerId this.attributeOwnerId = this } diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index c16f138f35f..3fc4cd63ad4 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -372,7 +372,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower private fun IrSimpleFunction.isCapturingCrossinline(): Boolean { var capturesCrossinline = false - (this.attributeOwnerIdBeforeInline ?: this).acceptVoid(object : IrElementVisitorVoid { + (this.originalBeforeInline ?: this).acceptVoid(object : IrElementVisitorVoid { override fun visitElement(element: IrElement) { element.acceptChildrenVoid(this) } diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInventNamesForLocalClasses.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInventNamesForLocalClasses.kt index 3fef2f8d089..5a2d8b68d4f 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInventNamesForLocalClasses.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInventNamesForLocalClasses.kt @@ -63,7 +63,7 @@ open class JvmInventNamesForLocalClasses( // TODO try to use only one "InventNames" class JvmInventNamesForInlinedAnonymousObjects(context: JvmBackendContext) : JvmInventNamesForLocalClasses(context, true) { override fun putLocalClassName(declaration: IrAttributeContainer, localClassName: String) { - if (declaration.attributeOwnerIdBeforeInline == null) return + if (declaration.originalBeforeInline == null) return context.putLocalClassType(declaration, Type.getObjectType(localClassName)) } } diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/MarkNecessaryInlinedClassesAsRegeneratedLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/MarkNecessaryInlinedClassesAsRegeneratedLowering.kt index f9339b55bea..fe46bf5483a 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/MarkNecessaryInlinedClassesAsRegeneratedLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/MarkNecessaryInlinedClassesAsRegeneratedLowering.kt @@ -101,7 +101,7 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo } if (!processingBeforeInlineDeclaration) { processingBeforeInlineDeclaration = true - declaration.attributeOwnerIdBeforeInline?.acceptChildrenVoid(this) // check if we need to save THIS declaration + declaration.originalBeforeInline?.acceptChildrenVoid(this) // check if we need to save THIS declaration processingBeforeInlineDeclaration = false } declaration.acceptChildrenVoid(this) // check if we need to save INNER declarations @@ -211,7 +211,7 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo this.acceptChildrenVoid(object : IrElementVisitorVoid { private fun checkAndSetUpCorrectAttributes(element: IrAttributeContainer) { when { - element !in mustBeRegenerated && element.attributeOwnerIdBeforeInline != null -> element.setUpOriginalAttributes() + element !in mustBeRegenerated && element.originalBeforeInline != null -> element.setUpOriginalAttributes() else -> element.acceptChildrenVoid(this) } } @@ -237,12 +237,12 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo private fun IrElement.setUpOriginalAttributes() { acceptVoid(object : IrElementVisitorVoid { override fun visitElement(element: IrElement) { - if (element is IrAttributeContainer && element.attributeOwnerIdBeforeInline != null) { - // Basically we need to generate SEQUENCE of `element.attributeOwnerIdBeforeInline` and find the original one. - // But we process nested inlined functions first, so `element.attributeOwnerIdBeforeInline` will be processed already. + if (element is IrAttributeContainer && element.originalBeforeInline != null) { + // Basically we need to generate SEQUENCE of `element.originalBeforeInline` and find the original one. + // But we process nested inlined functions first, so `element.originalBeforeInline` will be processed already. // This mean that when we start to precess current container, all inner ones in SEQUENCE will already be processed. - element.attributeOwnerId = element.attributeOwnerIdBeforeInline!!.attributeOwnerId - element.attributeOwnerIdBeforeInline = null + element.attributeOwnerId = element.originalBeforeInline!!.attributeOwnerId + element.originalBeforeInline = null } element.acceptChildrenVoid(this) } diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDuplicatedInlinedLocalClassesLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDuplicatedInlinedLocalClassesLowering.kt index 5a8311c91c6..c79a51ac111 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDuplicatedInlinedLocalClassesLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/RemoveDuplicatedInlinedLocalClassesLowering.kt @@ -35,7 +35,7 @@ internal val removeDuplicatedInlinedLocalClasses = makeIrFilePhase( // There are three types of inlined local classes: // 1. MUST BE regenerated according to set of rules in AnonymousObjectTransformationInfo. -// They all have `attributeOwnerIdBeforeInline != null`. +// They all have `originalBeforeInline != null`. // 2. MUST NOT BE regenerated and MUST BE CREATED only once because they are copied from call site. // This lambda will not exist after inline, so we copy declaration into new temporary inline call `singleArgumentInlineFunction`. // 3. MUST NOT BE created at all because will be created at callee site. @@ -132,10 +132,10 @@ class RemoveDuplicatedInlinedLocalClassesLowering(val context: JvmBackendContext } // Basically we want to remove all anonymous classes after inline. Exceptions are: - // 1. classes that must be regenerated (declaration.attributeOwnerIdBeforeInline != null) + // 1. classes that must be regenerated (declaration.originalBeforeInline != null) // 2. classes that are originally declared on call site or are default lambdas (data == true) override fun visitClass(declaration: IrClass, data: Boolean): IrStatement { - if (!insideInlineBlock || declaration.attributeOwnerIdBeforeInline != null || !data) { + if (!insideInlineBlock || declaration.originalBeforeInline != null || !data) { return super.visitClass(declaration, data) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrInlineUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrInlineUtils.kt index 86cab596749..05a240e3334 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrInlineUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrInlineUtils.kt @@ -92,7 +92,7 @@ fun IrFunction.isReifiable(): Boolean = typeParameters.any { it.isReified } private fun IrAttributeContainer.getDeclarationBeforeInline(): IrDeclaration? { - val original = this.attributeOwnerIdBeforeInline ?: return null + val original = this.originalBeforeInline ?: return null return when (original) { is IrClass -> return original is IrFunctionExpression -> original.function @@ -102,8 +102,8 @@ private fun IrAttributeContainer.getDeclarationBeforeInline(): IrDeclaration? { } fun IrAttributeContainer.getAttributeOwnerBeforeInline(): IrAttributeContainer? { - if (this.attributeOwnerIdBeforeInline == null) return null - return generateSequence(this) { it.attributeOwnerIdBeforeInline }.last() + if (this.originalBeforeInline == null) return null + return generateSequence(this) { it.originalBeforeInline }.last() } val IrDeclaration.fileParentBeforeInline: IrFile 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 6c755777b00..294c8c81a9d 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 @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.IrElement * useful, for example, to keep track of generated names for anonymous declarations. * @property attributeOwnerId original element before copying. Always satisfies the following * invariant: this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId. - * @property attributeOwnerIdBeforeInline original element before inlining. Useful only with IR + * @property originalBeforeInline original element before inlining. Useful only with IR * inliner. null if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the * idempotence invariant and can contain a chain of declarations. * @sample org.jetbrains.kotlin.ir.generator.IrTree.attributeContainer @@ -23,5 +23,5 @@ import org.jetbrains.kotlin.ir.IrElement interface IrAttributeContainer : IrElement { var attributeOwnerId: IrAttributeContainer - var attributeOwnerIdBeforeInline: IrAttributeContainer? + var originalBeforeInline: 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 e20a08be082..8610d1b1783 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,7 +22,7 @@ abstract class IrExpression : IrElementBase(), IrStatement, IrVarargElement, IrAttributeContainer { override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: IrAttributeContainer? = null abstract var type: IrType 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 4872a81ae6d..3e212a8ce60 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,7 +17,7 @@ import java.io.File fun D.copyAttributes(other: IrAttributeContainer?): D = apply { if (other != null) { attributeOwnerId = other.attributeOwnerId - attributeOwnerIdBeforeInline = other.attributeOwnerIdBeforeInline + originalBeforeInline = other.originalBeforeInline } } 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 eba8ded51d8..0567edc95e1 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,7 +57,7 @@ open class IrClassImpl( override var metadata: MetadataSource? = null override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: 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 26b5ec41405..a94fbc0323f 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,7 +64,7 @@ abstract class IrFunctionCommonImpl( @Suppress("LeakingThis") override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: 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 33958bd5aaf..73b4b3f1e1a 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,7 +45,7 @@ abstract class IrPropertyCommonImpl( override var metadata: MetadataSource? = null override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: 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 5ece1a317e3..c0c03b30cee 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,7 +108,7 @@ class IrLazyClass( } override var attributeOwnerId: IrAttributeContainer = this - override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null + override var originalBeforeInline: 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 5ff29c6b583..19306510981 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,9 +104,9 @@ class IrLazyFunction( get() = this set(_) = error("We should never need to change attributeOwnerId of external declarations.") - override var attributeOwnerIdBeforeInline: IrAttributeContainer? + override var originalBeforeInline: IrAttributeContainer? get() = null - set(_) = error("We should never need to change attributeOwnerIdBeforeInline of external declarations.") + set(_) = error("We should never need to change originalBeforeInline of external declarations.") override var correspondingPropertySymbol: IrPropertySymbol? = null 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 1a968776874..fbc39c994b0 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 @@ -89,7 +89,7 @@ class IrLazyProperty( get() = this set(_) = error("We should never need to change attributeOwnerId of external declarations.") - override var attributeOwnerIdBeforeInline: IrAttributeContainer? + override var originalBeforeInline: IrAttributeContainer? get() = this - set(_) = error("We should never need to change attributeOwnerIdBeforeInline of external declarations.") + set(_) = error("We should never need to change originalBeforeInline 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 04a3e1313c2..484e642ee52 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 @@ -175,13 +175,13 @@ object IrTree : AbstractTreeBuilder() { useful, for example, to keep track of generated names for anonymous declarations. @property attributeOwnerId original element before copying. Always satisfies the following invariant: `this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId`. - @property attributeOwnerIdBeforeInline original element before inlining. Useful only with IR + @property originalBeforeInline original element before inlining. Useful only with IR inliner. `null` if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the idempotence invariant and can contain a chain of declarations. """.trimIndent() +field("attributeOwnerId", attributeContainer) - +field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) // null <=> this element wasn't inlined + +field("originalBeforeInline", attributeContainer, nullable = true) // null <=> this element wasn't inlined } val anonymousInitializer: ElementConfig by element(Declaration) { visitorParent = declarationBase @@ -507,7 +507,7 @@ object IrTree : AbstractTreeBuilder() { +field("attributeOwnerId", attributeContainer) { baseDefaultValue = code("this") } - +field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) { + +field("originalBeforeInline", attributeContainer, nullable = true) { baseDefaultValue = code("null") } +field("type", irTypeType)