IR: propagate original declaration info via attributeOwnerId
For IrProperty, IrSimpleFunction we need to pass information about original declaration to JVM_IR codegen. Instead of descriptors, use the attributeOwnerId field.
This commit is contained in:
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
abstract class IrProperty : IrDeclarationBase(), IrOverridableMember, IrMetadataSourceOwner {
|
||||
abstract class IrProperty : IrDeclarationBase(), IrOverridableMember, IrMetadataSourceOwner, IrAttributeContainer {
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
abstract override val descriptor: PropertyDescriptor
|
||||
abstract override val symbol: IrPropertySymbol
|
||||
|
||||
@@ -86,7 +86,10 @@ class IrLazyFunction(
|
||||
stubGenerator.generateFunctionStub(it.original).symbol
|
||||
}
|
||||
}
|
||||
override var attributeOwnerId: IrAttributeContainer = this
|
||||
|
||||
override var attributeOwnerId: IrAttributeContainer
|
||||
get() = this
|
||||
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
||||
|
||||
override var correspondingPropertySymbol: IrPropertySymbol? = null
|
||||
|
||||
|
||||
@@ -78,4 +78,8 @@ class IrLazyProperty(
|
||||
override var metadata: MetadataSource?
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
override var attributeOwnerId: IrAttributeContainer
|
||||
get() = this
|
||||
set(_) = error("We should never need to change attributeOwnerId of external declarations.")
|
||||
}
|
||||
|
||||
@@ -547,3 +547,9 @@ fun IrExpression.isSafeToUseWithoutCopying() =
|
||||
this is IrGetEnumValue ||
|
||||
this is IrConst<*> ||
|
||||
this is IrGetValue && symbol.isBound && symbol.owner.isImmutable
|
||||
|
||||
val IrFunction.originalFunction: IrFunction
|
||||
get() = (this as? IrAttributeContainer)?.attributeOwnerId as? IrFunction ?: this
|
||||
|
||||
val IrProperty.originalProperty: IrProperty
|
||||
get() = attributeOwnerId as? IrProperty ?: this
|
||||
Reference in New Issue
Block a user