IR: move containerSource from descriptor to IrFunction, IrProperty
This commit is contained in:
+13
-8
@@ -367,7 +367,7 @@ class Fir2IrDeclarationStorage(
|
||||
): IrSimpleFunction {
|
||||
if (signature == null) {
|
||||
val descriptor =
|
||||
if (containerSource != null) WrappedFunctionDescriptorWithContainerSource(containerSource)
|
||||
if (containerSource != null) WrappedFunctionDescriptorWithContainerSource()
|
||||
else WrappedSimpleFunctionDescriptor()
|
||||
return symbolTable.declareSimpleFunction(descriptor, factory).apply { descriptor.bind(this) }
|
||||
}
|
||||
@@ -411,7 +411,8 @@ class Fir2IrDeclarationStorage(
|
||||
isExpect = simpleFunction?.isExpect == true,
|
||||
isFakeOverride = updatedOrigin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
isOperator = simpleFunction?.isOperator == true,
|
||||
isInfix = simpleFunction?.isInfix == true
|
||||
isInfix = simpleFunction?.isInfix == true,
|
||||
containerSource = simpleFunction?.containerSource,
|
||||
).apply {
|
||||
metadata = FirMetadataSource.Function(function)
|
||||
convertAnnotationsFromLibrary(function)
|
||||
@@ -522,9 +523,11 @@ class Fir2IrDeclarationStorage(
|
||||
): IrSimpleFunction {
|
||||
val prefix = if (isSetter) "set" else "get"
|
||||
val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter)
|
||||
val containerSource =
|
||||
(correspondingProperty.descriptor as? WrappedPropertyDescriptorWithContainerSource)?.containerSource
|
||||
return declareIrAccessor(
|
||||
signature,
|
||||
(correspondingProperty.descriptor as? WrappedPropertyDescriptorWithContainerSource)?.containerSource,
|
||||
containerSource,
|
||||
isGetter = !isSetter
|
||||
) { symbol ->
|
||||
val accessorReturnType = if (isSetter) irBuiltIns.unitType else propertyType
|
||||
@@ -535,9 +538,10 @@ class Fir2IrDeclarationStorage(
|
||||
correspondingProperty.modality, accessorReturnType,
|
||||
isInline = propertyAccessor?.isInline == true,
|
||||
isExternal = propertyAccessor?.isExternal == true,
|
||||
isTailrec = false, isSuspend = false, isExpect = false,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
isOperator = false, isInfix = false
|
||||
isTailrec = false, isSuspend = false, isOperator = false,
|
||||
isInfix = false,
|
||||
isExpect = false, isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
containerSource = containerSource,
|
||||
).apply {
|
||||
correspondingPropertySymbol = correspondingProperty.symbol
|
||||
if (propertyAccessor != null) {
|
||||
@@ -618,7 +622,7 @@ class Fir2IrDeclarationStorage(
|
||||
): IrProperty {
|
||||
if (signature == null) {
|
||||
val descriptor =
|
||||
if (containerSource != null) WrappedPropertyDescriptorWithContainerSource(containerSource)
|
||||
if (containerSource != null) WrappedPropertyDescriptorWithContainerSource()
|
||||
else WrappedPropertyDescriptor()
|
||||
return symbolTable.declareProperty(0, 0, IrDeclarationOrigin.DEFINED, descriptor, isDelegated = false, factory).apply {
|
||||
descriptor.bind(this)
|
||||
@@ -647,7 +651,8 @@ class Fir2IrDeclarationStorage(
|
||||
isDelegated = property.delegate != null,
|
||||
isExternal = property.isExternal,
|
||||
isExpect = property.isExpect,
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
|
||||
containerSource = property.containerSource,
|
||||
).apply {
|
||||
metadata = FirMetadataSource.Variable(property)
|
||||
convertAnnotationsFromLibrary(property)
|
||||
|
||||
+2
-2
@@ -237,8 +237,8 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
|
||||
return components.declarationStorage.declareIrSimpleFunction(signature, null) { symbol ->
|
||||
components.irFactory.createFunction(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, symbol, name, Visibilities.PUBLIC, Modality.OPEN, returnType,
|
||||
isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isExpect = false,
|
||||
isFakeOverride = false, isOperator = false, isInfix = false,
|
||||
isInline = false, isExternal = false, isTailrec = false, isSuspend = false, isOperator = false,
|
||||
isInfix = false, isExpect = false, isFakeOverride = false,
|
||||
).apply {
|
||||
if (otherParameterNeeded) {
|
||||
val irValueParameter = createSyntheticIrParameter(
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
class Fir2IrLazyConstructor(
|
||||
components: Fir2IrComponents,
|
||||
@@ -109,6 +110,9 @@ class Fir2IrLazyConstructor(
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
get() = fir.containerSource
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
|
||||
return visitor.visitConstructor(this, data)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.types.IrErrorType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.isInterface
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
class Fir2IrLazyProperty(
|
||||
components: Fir2IrComponents,
|
||||
@@ -149,4 +150,7 @@ class Fir2IrLazyProperty(
|
||||
override var metadata: MetadataSource?
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
get() = fir.containerSource
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
class Fir2IrLazySimpleFunction(
|
||||
components: Fir2IrComponents,
|
||||
@@ -137,4 +138,7 @@ class Fir2IrLazySimpleFunction(
|
||||
override var metadata: MetadataSource?
|
||||
get() = null
|
||||
set(_) = error("We should never need to store metadata of external declarations.")
|
||||
|
||||
override val containerSource: DeserializedContainerSource?
|
||||
get() = fir.containerSource
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
is IrConstructor -> WrappedClassConstructorDescriptor().apply { bind(owner) }
|
||||
is IrSimpleFunction -> when {
|
||||
containerSource != null ->
|
||||
WrappedFunctionDescriptorWithContainerSource(containerSource)
|
||||
WrappedFunctionDescriptorWithContainerSource()
|
||||
owner.name.isSpecial && owner.name.asString().startsWith(GETTER_PREFIX) ->
|
||||
WrappedPropertyGetterDescriptor(Annotations.EMPTY, SourceElement.NO_SOURCE)
|
||||
owner.name.isSpecial && owner.name.asString().startsWith(SETTER_PREFIX) ->
|
||||
@@ -57,7 +57,7 @@ abstract class Fir2IrBindableSymbol<out D : DeclarationDescriptor, B : IrSymbolO
|
||||
is IrValueParameter -> WrappedValueParameterDescriptor().apply { bind(owner) }
|
||||
is IrTypeParameter -> WrappedTypeParameterDescriptor().apply { bind(owner) }
|
||||
is IrProperty -> if (containerSource != null) {
|
||||
WrappedPropertyDescriptorWithContainerSource(containerSource)
|
||||
WrappedPropertyDescriptorWithContainerSource()
|
||||
} else {
|
||||
WrappedPropertyDescriptor()
|
||||
}.apply { bind(owner) }
|
||||
|
||||
Reference in New Issue
Block a user