psi2ir: no unbound field symbols in delegated property references

#KT-30323 Fixed
This commit is contained in:
Dmitry Petrov
2019-03-07 11:18:49 +03:00
parent 15918fc475
commit 9f48695dde
8 changed files with 18 additions and 11 deletions
@@ -199,7 +199,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
private fun createCallableReference(
ktElement: KtElement,
type: KotlinType,
referencedDescriptor: CallableDescriptor,
referencedDescriptor: VariableDescriptorWithAccessors,
scopeOwner: IrSymbol
): IrCallableReference =
createCallableReference(
@@ -142,9 +142,9 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
return IrPropertyReferenceImpl(
startOffset, endOffset, type.toIrType(),
context.symbolTable.referenceProperty(propertyDescriptor.original),
context.symbolTable.referenceProperty(originalProperty),
propertyDescriptor.typeParametersCount,
originalGetter?.run { context.symbolTable.referenceField(originalProperty) },
getFieldForPropertyReference(originalProperty),
originalGetter?.let { context.symbolTable.referenceSimpleFunction(it) },
originalSetter?.let { context.symbolTable.referenceSimpleFunction(it) },
origin
@@ -153,6 +153,14 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St
}
}
private fun getFieldForPropertyReference(originalProperty: PropertyDescriptor) =
// NB this is a hack, we really don't know if an arbitrary property has a backing field or not
when {
originalProperty.isDelegated -> null
originalProperty.getter != null -> null
else -> context.symbolTable.referenceField(originalProperty)
}
private fun generateFunctionReference(
startOffset: Int,
endOffset: Int,