IR: introduce WrappedProperty{G,S}etterDescriptor

This is needed in order to support wrapped properties properly in
KotlinTypeMapper (see the `is PropertyAccessorDescriptor` call in
`mapFunctionName`) which is still being used when mapping function call
signatures
This commit is contained in:
Alexander Udalov
2019-07-19 17:28:03 +02:00
parent cfd3d974d1
commit 28e2fd63ca
2 changed files with 34 additions and 6 deletions
@@ -40,7 +40,11 @@ object DescriptorsToIrRemapper : DescriptorsRemapper {
WrappedFieldDescriptor(descriptor.annotations, descriptor.source)
override fun remapDeclaredSimpleFunction(descriptor: FunctionDescriptor) =
WrappedSimpleFunctionDescriptor(descriptor.annotations, descriptor.source)
when (descriptor) {
is PropertyGetterDescriptor -> WrappedPropertyGetterDescriptor(descriptor.annotations, descriptor.source)
is PropertySetterDescriptor -> WrappedPropertySetterDescriptor(descriptor.annotations, descriptor.source)
else -> WrappedSimpleFunctionDescriptor(descriptor.annotations, descriptor.source)
}
override fun remapDeclaredProperty(descriptor: PropertyDescriptor) =
WrappedPropertyDescriptor(descriptor.annotations, descriptor.source)
@@ -434,7 +434,7 @@ open class WrappedSimpleFunctionDescriptor(
visibility: Visibility?,
kind: CallableMemberDescriptor.Kind?,
copyOverrides: Boolean
): SimpleFunctionDescriptor {
): Nothing {
TODO("not implemented")
}
@@ -797,10 +797,7 @@ open class WrappedPropertyDescriptor(
TODO("not implemented")
}
override fun getAccessors(): MutableList<PropertyAccessorDescriptor> = listOfNotNull(
owner.getter?.descriptor as? PropertyAccessorDescriptor,
owner.setter?.descriptor as? PropertyAccessorDescriptor
).toMutableList()
override fun getAccessors(): List<PropertyAccessorDescriptor> = listOfNotNull(getter, setter)
override fun getTypeParameters(): List<TypeParameterDescriptor> = emptyList()
@@ -867,6 +864,33 @@ class WrappedPropertyDescriptorWithContainerSource(
override var containerSource: DeserializedContainerSource
) : WrappedPropertyDescriptor(), DescriptorWithContainerSource
abstract class WrappedPropertyAccessorDescriptor(annotations: Annotations, sourceElement: SourceElement) :
WrappedSimpleFunctionDescriptor(annotations, sourceElement), PropertyAccessorDescriptor {
override fun isDefault(): Boolean = false
override fun getOriginal(): WrappedPropertyAccessorDescriptor = this
override fun getOverriddenDescriptors() = super.getOverriddenDescriptors().map { it as PropertyAccessorDescriptor }
override fun getCorrespondingProperty(): PropertyDescriptor = owner.correspondingPropertySymbol!!.descriptor
override val correspondingVariable: VariableDescriptorWithAccessors get() = correspondingProperty
}
class WrappedPropertyGetterDescriptor(annotations: Annotations, sourceElement: SourceElement) :
WrappedPropertyAccessorDescriptor(annotations, sourceElement), PropertyGetterDescriptor {
override fun getOverriddenDescriptors() = super.getOverriddenDescriptors().map { it as PropertyGetterDescriptor }
override fun getOriginal(): WrappedPropertyGetterDescriptor = this
}
class WrappedPropertySetterDescriptor(annotations: Annotations, sourceElement: SourceElement) :
WrappedPropertyAccessorDescriptor(annotations, sourceElement), PropertySetterDescriptor {
override fun getOverriddenDescriptors() = super.getOverriddenDescriptors().map { it as PropertySetterDescriptor }
override fun getOriginal(): WrappedPropertySetterDescriptor = this
}
open class WrappedFieldDescriptor(
annotations: Annotations = Annotations.EMPTY,
private val sourceElement: SourceElement = SourceElement.NO_SOURCE