Rename attributeOwnerIdBeforeInline to originalBeforeInline
This commit is contained in:
@@ -91,7 +91,7 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
|
|||||||
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
|
|
||||||
override var metadata: MetadataSource?
|
override var metadata: MetadataSource?
|
||||||
get() = null
|
get() = null
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ class Fir2IrLazyClass(
|
|||||||
get() = this
|
get() = this
|
||||||
set(_) = mutationNotSupported()
|
set(_) = mutationNotSupported()
|
||||||
|
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
|
override var originalBeforeInline: IrAttributeContainer?
|
||||||
get() = null
|
get() = null
|
||||||
set(_) {
|
set(_) {
|
||||||
error("Mutating Fir2Ir lazy elements is not possible")
|
error("Mutating Fir2Ir lazy elements is not possible")
|
||||||
|
|||||||
@@ -235,5 +235,5 @@ class Fir2IrLazyProperty(
|
|||||||
get() = fir.containerSource
|
get() = fir.containerSource
|
||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -142,7 +142,7 @@ abstract class InventNamesForLocalClasses(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunctionReference(expression: IrFunctionReference, data: Data) {
|
override fun visitFunctionReference(expression: IrFunctionReference, data: Data) {
|
||||||
if (data.processingInlinedFunction && expression.attributeOwnerIdBeforeInline == null) {
|
if (data.processingInlinedFunction && expression.originalBeforeInline == null) {
|
||||||
// skip IrFunctionReference from `singleArgumentInlineFunction`
|
// skip IrFunctionReference from `singleArgumentInlineFunction`
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -141,7 +141,7 @@ class FunctionInlining(
|
|||||||
acceptVoid(object : IrElementVisitorVoid {
|
acceptVoid(object : IrElementVisitorVoid {
|
||||||
private fun IrAttributeContainer.setUpCorrectAttributeOwner() {
|
private fun IrAttributeContainer.setUpCorrectAttributeOwner() {
|
||||||
if (this.attributeOwnerId == this) return
|
if (this.attributeOwnerId == this) return
|
||||||
this.attributeOwnerIdBeforeInline = this.attributeOwnerId
|
this.originalBeforeInline = this.attributeOwnerId
|
||||||
this.attributeOwnerId = this
|
this.attributeOwnerId = this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -372,7 +372,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower
|
|||||||
|
|
||||||
private fun IrSimpleFunction.isCapturingCrossinline(): Boolean {
|
private fun IrSimpleFunction.isCapturingCrossinline(): Boolean {
|
||||||
var capturesCrossinline = false
|
var capturesCrossinline = false
|
||||||
(this.attributeOwnerIdBeforeInline ?: this).acceptVoid(object : IrElementVisitorVoid {
|
(this.originalBeforeInline ?: this).acceptVoid(object : IrElementVisitorVoid {
|
||||||
override fun visitElement(element: IrElement) {
|
override fun visitElement(element: IrElement) {
|
||||||
element.acceptChildrenVoid(this)
|
element.acceptChildrenVoid(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ open class JvmInventNamesForLocalClasses(
|
|||||||
// TODO try to use only one "InventNames"
|
// TODO try to use only one "InventNames"
|
||||||
class JvmInventNamesForInlinedAnonymousObjects(context: JvmBackendContext) : JvmInventNamesForLocalClasses(context, true) {
|
class JvmInventNamesForInlinedAnonymousObjects(context: JvmBackendContext) : JvmInventNamesForLocalClasses(context, true) {
|
||||||
override fun putLocalClassName(declaration: IrAttributeContainer, localClassName: String) {
|
override fun putLocalClassName(declaration: IrAttributeContainer, localClassName: String) {
|
||||||
if (declaration.attributeOwnerIdBeforeInline == null) return
|
if (declaration.originalBeforeInline == null) return
|
||||||
context.putLocalClassType(declaration, Type.getObjectType(localClassName))
|
context.putLocalClassType(declaration, Type.getObjectType(localClassName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -101,7 +101,7 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo
|
|||||||
}
|
}
|
||||||
if (!processingBeforeInlineDeclaration) {
|
if (!processingBeforeInlineDeclaration) {
|
||||||
processingBeforeInlineDeclaration = true
|
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
|
processingBeforeInlineDeclaration = false
|
||||||
}
|
}
|
||||||
declaration.acceptChildrenVoid(this) // check if we need to save INNER declarations
|
declaration.acceptChildrenVoid(this) // check if we need to save INNER declarations
|
||||||
@@ -211,7 +211,7 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo
|
|||||||
this.acceptChildrenVoid(object : IrElementVisitorVoid {
|
this.acceptChildrenVoid(object : IrElementVisitorVoid {
|
||||||
private fun checkAndSetUpCorrectAttributes(element: IrAttributeContainer) {
|
private fun checkAndSetUpCorrectAttributes(element: IrAttributeContainer) {
|
||||||
when {
|
when {
|
||||||
element !in mustBeRegenerated && element.attributeOwnerIdBeforeInline != null -> element.setUpOriginalAttributes()
|
element !in mustBeRegenerated && element.originalBeforeInline != null -> element.setUpOriginalAttributes()
|
||||||
else -> element.acceptChildrenVoid(this)
|
else -> element.acceptChildrenVoid(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,12 +237,12 @@ class MarkNecessaryInlinedClassesAsRegeneratedLowering(val context: JvmBackendCo
|
|||||||
private fun IrElement.setUpOriginalAttributes() {
|
private fun IrElement.setUpOriginalAttributes() {
|
||||||
acceptVoid(object : IrElementVisitorVoid {
|
acceptVoid(object : IrElementVisitorVoid {
|
||||||
override fun visitElement(element: IrElement) {
|
override fun visitElement(element: IrElement) {
|
||||||
if (element is IrAttributeContainer && element.attributeOwnerIdBeforeInline != null) {
|
if (element is IrAttributeContainer && element.originalBeforeInline != null) {
|
||||||
// Basically we need to generate SEQUENCE of `element.attributeOwnerIdBeforeInline` and find the original one.
|
// Basically we need to generate SEQUENCE of `element.originalBeforeInline` and find the original one.
|
||||||
// But we process nested inlined functions first, so `element.attributeOwnerIdBeforeInline` will be processed already.
|
// 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.
|
// 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.attributeOwnerId = element.originalBeforeInline!!.attributeOwnerId
|
||||||
element.attributeOwnerIdBeforeInline = null
|
element.originalBeforeInline = null
|
||||||
}
|
}
|
||||||
element.acceptChildrenVoid(this)
|
element.acceptChildrenVoid(this)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -35,7 +35,7 @@ internal val removeDuplicatedInlinedLocalClasses = makeIrFilePhase(
|
|||||||
|
|
||||||
// There are three types of inlined local classes:
|
// There are three types of inlined local classes:
|
||||||
// 1. MUST BE regenerated according to set of rules in AnonymousObjectTransformationInfo.
|
// 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.
|
// 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`.
|
// 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.
|
// 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:
|
// 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)
|
// 2. classes that are originally declared on call site or are default lambdas (data == true)
|
||||||
override fun visitClass(declaration: IrClass, data: Boolean): IrStatement {
|
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)
|
return super.visitClass(declaration, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ fun IrFunction.isReifiable(): Boolean =
|
|||||||
typeParameters.any { it.isReified }
|
typeParameters.any { it.isReified }
|
||||||
|
|
||||||
private fun IrAttributeContainer.getDeclarationBeforeInline(): IrDeclaration? {
|
private fun IrAttributeContainer.getDeclarationBeforeInline(): IrDeclaration? {
|
||||||
val original = this.attributeOwnerIdBeforeInline ?: return null
|
val original = this.originalBeforeInline ?: return null
|
||||||
return when (original) {
|
return when (original) {
|
||||||
is IrClass -> return original
|
is IrClass -> return original
|
||||||
is IrFunctionExpression -> original.function
|
is IrFunctionExpression -> original.function
|
||||||
@@ -102,8 +102,8 @@ private fun IrAttributeContainer.getDeclarationBeforeInline(): IrDeclaration? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun IrAttributeContainer.getAttributeOwnerBeforeInline(): IrAttributeContainer? {
|
fun IrAttributeContainer.getAttributeOwnerBeforeInline(): IrAttributeContainer? {
|
||||||
if (this.attributeOwnerIdBeforeInline == null) return null
|
if (this.originalBeforeInline == null) return null
|
||||||
return generateSequence(this) { it.attributeOwnerIdBeforeInline }.last()
|
return generateSequence(this) { it.originalBeforeInline }.last()
|
||||||
}
|
}
|
||||||
|
|
||||||
val IrDeclaration.fileParentBeforeInline: IrFile
|
val IrDeclaration.fileParentBeforeInline: IrFile
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
* useful, for example, to keep track of generated names for anonymous declarations.
|
* useful, for example, to keep track of generated names for anonymous declarations.
|
||||||
* @property attributeOwnerId original element before copying. Always satisfies the following
|
* @property attributeOwnerId original element before copying. Always satisfies the following
|
||||||
* invariant: this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId.
|
* 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
|
* inliner. null if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the
|
||||||
* idempotence invariant and can contain a chain of declarations.
|
* idempotence invariant and can contain a chain of declarations.
|
||||||
* @sample org.jetbrains.kotlin.ir.generator.IrTree.attributeContainer
|
* @sample org.jetbrains.kotlin.ir.generator.IrTree.attributeContainer
|
||||||
@@ -23,5 +23,5 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
interface IrAttributeContainer : IrElement {
|
interface IrAttributeContainer : IrElement {
|
||||||
var attributeOwnerId: IrAttributeContainer
|
var attributeOwnerId: IrAttributeContainer
|
||||||
|
|
||||||
var attributeOwnerIdBeforeInline: IrAttributeContainer?
|
var originalBeforeInline: IrAttributeContainer?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ abstract class IrExpression : IrElementBase(), IrStatement, IrVarargElement,
|
|||||||
IrAttributeContainer {
|
IrAttributeContainer {
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
|
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
|
|
||||||
abstract var type: IrType
|
abstract var type: IrType
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import java.io.File
|
|||||||
fun <D : IrAttributeContainer> D.copyAttributes(other: IrAttributeContainer?): D = apply {
|
fun <D : IrAttributeContainer> D.copyAttributes(other: IrAttributeContainer?): D = apply {
|
||||||
if (other != null) {
|
if (other != null) {
|
||||||
attributeOwnerId = other.attributeOwnerId
|
attributeOwnerId = other.attributeOwnerId
|
||||||
attributeOwnerIdBeforeInline = other.attributeOwnerIdBeforeInline
|
originalBeforeInline = other.originalBeforeInline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ open class IrClassImpl(
|
|||||||
override var metadata: MetadataSource? = null
|
override var metadata: MetadataSource? = null
|
||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
|
|
||||||
override var sealedSubclasses: List<IrClassSymbol> = emptyList()
|
override var sealedSubclasses: List<IrClassSymbol> = emptyList()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ abstract class IrFunctionCommonImpl(
|
|||||||
|
|
||||||
@Suppress("LeakingThis")
|
@Suppress("LeakingThis")
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
|
|
||||||
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ abstract class IrPropertyCommonImpl(
|
|||||||
override var metadata: MetadataSource? = null
|
override var metadata: MetadataSource? = null
|
||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
override var attributeOwnerId: IrAttributeContainer = this
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer? = null
|
override var originalBeforeInline: IrAttributeContainer? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
class IrPropertyImpl(
|
class IrPropertyImpl(
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class IrLazyClass(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override var attributeOwnerId: IrAttributeContainer = this
|
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 classProto: ProtoBuf.Class? get() = (descriptor as? DeserializedClassDescriptor)?.classProto
|
||||||
val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
val nameResolver: NameResolver? get() = (descriptor as? DeserializedClassDescriptor)?.c?.nameResolver
|
||||||
|
|||||||
@@ -104,9 +104,9 @@ class IrLazyFunction(
|
|||||||
get() = this
|
get() = this
|
||||||
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
||||||
|
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
|
override var originalBeforeInline: IrAttributeContainer?
|
||||||
get() = null
|
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
|
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class IrLazyProperty(
|
|||||||
get() = this
|
get() = this
|
||||||
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
||||||
|
|
||||||
override var attributeOwnerIdBeforeInline: IrAttributeContainer?
|
override var originalBeforeInline: IrAttributeContainer?
|
||||||
get() = this
|
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.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,13 +175,13 @@ object IrTree : AbstractTreeBuilder() {
|
|||||||
useful, for example, to keep track of generated names for anonymous declarations.
|
useful, for example, to keep track of generated names for anonymous declarations.
|
||||||
@property attributeOwnerId original element before copying. Always satisfies the following
|
@property attributeOwnerId original element before copying. Always satisfies the following
|
||||||
invariant: `this.attributeOwnerId == this.attributeOwnerId.attributeOwnerId`.
|
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
|
inliner. `null` if the element wasn't inlined. Unlike [attributeOwnerId], doesn't have the
|
||||||
idempotence invariant and can contain a chain of declarations.
|
idempotence invariant and can contain a chain of declarations.
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
+field("attributeOwnerId", attributeContainer)
|
+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) {
|
val anonymousInitializer: ElementConfig by element(Declaration) {
|
||||||
visitorParent = declarationBase
|
visitorParent = declarationBase
|
||||||
@@ -507,7 +507,7 @@ object IrTree : AbstractTreeBuilder() {
|
|||||||
+field("attributeOwnerId", attributeContainer) {
|
+field("attributeOwnerId", attributeContainer) {
|
||||||
baseDefaultValue = code("this")
|
baseDefaultValue = code("this")
|
||||||
}
|
}
|
||||||
+field("attributeOwnerIdBeforeInline", attributeContainer, nullable = true) {
|
+field("originalBeforeInline", attributeContainer, nullable = true) {
|
||||||
baseDefaultValue = code("null")
|
baseDefaultValue = code("null")
|
||||||
}
|
}
|
||||||
+field("type", irTypeType)
|
+field("type", irTypeType)
|
||||||
|
|||||||
Reference in New Issue
Block a user