IR KT-46578 add IrProperty#overriddenSymbols
This commit is contained in:
committed by
teamcityserver
parent
dc9d5cdf35
commit
53c1de172f
+20
-7
@@ -59,6 +59,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
irProperty.setter = generateSetterIfRequired(ktEntry, propertyDescriptor)
|
||||
|
||||
irProperty.linkCorrespondingPropertySymbol()
|
||||
irProperty.generateOverrides(propertyDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +69,10 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
}
|
||||
|
||||
fun generateSyntheticProperty(
|
||||
ktDeclarationContainer: KtElement, propertyDescriptor: PropertyDescriptor,
|
||||
irValueParameter: IrValueParameter?, generateSyntheticAccessors: Boolean = false
|
||||
ktDeclarationContainer: KtElement,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
irValueParameter: IrValueParameter?,
|
||||
generateSyntheticAccessors: Boolean = false
|
||||
): IrProperty {
|
||||
val irPropertyType = propertyDescriptor.type.toIrType()
|
||||
return generateSyntheticPropertyWithInitializer(ktDeclarationContainer, propertyDescriptor, generateSyntheticAccessors) {
|
||||
@@ -88,8 +91,10 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
}
|
||||
|
||||
fun generateSyntheticPropertyWithInitializer(
|
||||
ktDeclarationContainer: KtElement, propertyDescriptor: PropertyDescriptor,
|
||||
generateSyntheticAccessors: Boolean, generateInitializer: (IrField) -> IrExpressionBody?
|
||||
ktDeclarationContainer: KtElement,
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
generateSyntheticAccessors: Boolean,
|
||||
generateInitializer: (IrField) -> IrExpressionBody?
|
||||
): IrProperty {
|
||||
return context.symbolTable.declareProperty(
|
||||
ktDeclarationContainer.startOffsetSkippingComments, ktDeclarationContainer.endOffset,
|
||||
@@ -141,6 +146,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
}
|
||||
|
||||
irProperty.linkCorrespondingPropertySymbol()
|
||||
irProperty.generateOverrides(propertyDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +172,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
): IrProperty =
|
||||
DelegatedPropertyGenerator(declarationGenerator)
|
||||
.generateDelegatedProperty(ktProperty, ktDelegate, propertyDescriptor)
|
||||
.apply { generateOverrides(propertyDescriptor) }
|
||||
|
||||
private fun PropertyDescriptor.actuallyHasBackingField(bindingContext: BindingContext) =
|
||||
hasBackingField(bindingContext) || context.extensions.isPropertyWithPlatformField(this)
|
||||
@@ -208,6 +215,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
irProperty.setter = generateSetterIfRequired(ktProperty, propertyDescriptor)
|
||||
|
||||
irProperty.linkCorrespondingPropertySymbol()
|
||||
irProperty.generateOverrides(propertyDescriptor)
|
||||
}
|
||||
|
||||
fun generateFakeOverrideProperty(propertyDescriptor: PropertyDescriptor, ktElement: KtPureElement): IrProperty? {
|
||||
@@ -224,9 +232,17 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
FunctionGenerator(declarationGenerator).generateFakeOverrideFunction(it, ktElement)
|
||||
}
|
||||
this.linkCorrespondingPropertySymbol()
|
||||
this.generateOverrides(propertyDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrProperty.generateOverrides(propertyDescriptor: PropertyDescriptor) {
|
||||
overriddenSymbols =
|
||||
propertyDescriptor.overriddenDescriptors.map { overriddenPropertyDescriptor ->
|
||||
context.symbolTable.referenceProperty(overriddenPropertyDescriptor.original)
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateGetterIfRequired(ktProperty: KtVariableDeclaration, property: PropertyDescriptor): IrSimpleFunction? {
|
||||
val getter = property.getter ?: return null
|
||||
return FunctionGenerator(declarationGenerator).generatePropertyAccessor(getter, ktProperty, (ktProperty as? KtProperty)?.getter)
|
||||
@@ -243,9 +259,6 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
return variableDescriptor as? PropertyDescriptor ?: TODO("not a property: $variableDescriptor")
|
||||
}
|
||||
|
||||
private val DescriptorVisibility.admitsFakeOverride: Boolean
|
||||
get() = !DescriptorVisibilities.isPrivate(this) && this != DescriptorVisibilities.INVISIBLE_FAKE
|
||||
|
||||
private val PropertyDescriptor.fieldVisibility: DescriptorVisibility
|
||||
get() = declarationGenerator.context.extensions.computeFieldVisibility(this)
|
||||
?: when {
|
||||
|
||||
+8
-1
@@ -426,7 +426,11 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
||||
}
|
||||
}
|
||||
|
||||
private class DelegatedPropertySymbols(val propertySymbol: IrPropertySymbol, val getterSymbol: IrSimpleFunctionSymbol?, val setterSymbol: IrSimpleFunctionSymbol?)
|
||||
private class DelegatedPropertySymbols(
|
||||
val propertySymbol: IrPropertySymbol,
|
||||
val getterSymbol: IrSimpleFunctionSymbol?,
|
||||
val setterSymbol: IrSimpleFunctionSymbol?
|
||||
)
|
||||
|
||||
private class IrSyntheticJavaProperty(
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
@@ -453,6 +457,9 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
|
||||
get() = descriptor.isExpect
|
||||
override val isFakeOverride: Boolean
|
||||
get() = false
|
||||
override var overriddenSymbols: List<IrPropertySymbol>
|
||||
get() = emptyList()
|
||||
set(_) {}
|
||||
override var backingField: IrField?
|
||||
get() = null
|
||||
set(_) {}
|
||||
|
||||
Reference in New Issue
Block a user