[psi2ir] Properly link corresponding property symbols.
Do not rely on PatchDeclarationParents to do so.
This commit is contained in:
committed by
Alexander Udalov
parent
8bc360fa0c
commit
eec3263518
@@ -275,6 +275,9 @@ class ClassGenerator(
|
|||||||
if (delegatedDescriptor.isVar) {
|
if (delegatedDescriptor.isVar) {
|
||||||
irProperty.setter = generateDelegatedFunction(irDelegate, delegatedDescriptor.setter!!, delegateToDescriptor.setter!!)
|
irProperty.setter = generateDelegatedFunction(irDelegate, delegatedDescriptor.setter!!, delegateToDescriptor.setter!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irProperty.linkCorrespondingPropertySymbol()
|
||||||
|
|
||||||
return irProperty
|
return irProperty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -86,6 +86,8 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irProperty.linkCorrespondingPropertySymbol()
|
||||||
|
|
||||||
return irProperty
|
return irProperty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
irProperty.setter =
|
irProperty.setter =
|
||||||
FunctionGenerator(declarationGenerator).generateDefaultAccessorForPrimaryConstructorParameter(setter, ktParameter)
|
FunctionGenerator(declarationGenerator).generateDefaultAccessorForPrimaryConstructorParameter(setter, ktParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
irProperty.linkCorrespondingPropertySymbol()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +135,8 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
|
|
||||||
irProperty.getter = generateGetterIfRequired(ktProperty, propertyDescriptor)
|
irProperty.getter = generateGetterIfRequired(ktProperty, propertyDescriptor)
|
||||||
irProperty.setter = generateSetterIfRequired(ktProperty, propertyDescriptor)
|
irProperty.setter = generateSetterIfRequired(ktProperty, propertyDescriptor)
|
||||||
|
|
||||||
|
irProperty.linkCorrespondingPropertySymbol()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun generateFakeOverrideProperty(propertyDescriptor: PropertyDescriptor, ktElement: KtPureElement): IrProperty? {
|
fun generateFakeOverrideProperty(propertyDescriptor: PropertyDescriptor, ktElement: KtPureElement): IrProperty? {
|
||||||
@@ -158,6 +162,7 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
this.setter = propertyDescriptor.setter?.let {
|
this.setter = propertyDescriptor.setter?.let {
|
||||||
FunctionGenerator(declarationGenerator).generateFakeOverrideFunction(it, ktElement)
|
FunctionGenerator(declarationGenerator).generateFakeOverrideFunction(it, ktElement)
|
||||||
}
|
}
|
||||||
|
this.linkCorrespondingPropertySymbol()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,3 +194,10 @@ class PropertyGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun IrProperty.linkCorrespondingPropertySymbol() {
|
||||||
|
backingField?.correspondingPropertySymbol = symbol
|
||||||
|
getter?.correspondingPropertySymbol = symbol
|
||||||
|
setter?.correspondingPropertySymbol = symbol
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,19 +53,6 @@ class PatchDeclarationParentsVisitor() : IrElementVisitorVoid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitProperty(declaration: IrProperty) {
|
|
||||||
declaration.getter?.let {
|
|
||||||
it.correspondingPropertySymbol = declaration.symbol
|
|
||||||
}
|
|
||||||
declaration.setter?.let {
|
|
||||||
it.correspondingPropertySymbol = declaration.symbol
|
|
||||||
}
|
|
||||||
declaration.backingField?.let {
|
|
||||||
it.correspondingPropertySymbol = declaration.symbol
|
|
||||||
}
|
|
||||||
super.visitProperty(declaration)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun patchParent(declaration: IrDeclaration) {
|
private fun patchParent(declaration: IrDeclaration) {
|
||||||
declaration.parent = declarationParentsStack.peekFirst()
|
declaration.parent = declarationParentsStack.peekFirst()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user