IR: mark interface delegate fields as synthetic

This requires separating them origin-wise from property delegates.
This commit is contained in:
pyos
2020-01-20 14:26:46 +01:00
committed by Dmitry Petrov
parent ce1f746c5e
commit f1669e2230
31 changed files with 125 additions and 124 deletions
@@ -320,7 +320,7 @@ open class ClassCodegen protected constructor(
val fieldType = typeMapper.mapType(field)
val fieldSignature =
if (field.origin == IrDeclarationOrigin.DELEGATE) null
if (field.origin == IrDeclarationOrigin.PROPERTY_DELEGATE) null
else methodSignatureMapper.mapFieldSignature(field)
val fieldName = field.name.asString()
val fv = visitor.newField(
@@ -36,7 +36,7 @@ class AnnotationGenerator(context: GeneratorContext) : IrElementVisitorVoid {
// Delegate field is mapped to a new property descriptor with annotations of the original property delegate
// (see IrPropertyDelegateDescriptorImpl), but annotations on backing fields should be processed manually here
val annotatedDescriptor =
if (declaration is IrField && declaration.origin != IrDeclarationOrigin.DELEGATE)
if (declaration is IrField && declaration.origin != IrDeclarationOrigin.PROPERTY_DELEGATE)
declaration.descriptor.backingField
else declaration.descriptor
@@ -125,7 +125,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
val startOffset = ktDelegate.startOffsetSkippingComments
val endOffset = ktDelegate.endOffset
val origin = IrDeclarationOrigin.DELEGATE
val origin = IrDeclarationOrigin.PROPERTY_DELEGATE
val type = delegateDescriptor.type.toIrType()
return context.symbolTable.declareField(
startOffset, endOffset, origin, delegateDescriptor, type
@@ -287,7 +287,7 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
val delegateDescriptor = createLocalPropertyDelegatedDescriptor(variableDescriptor, delegateType, kPropertyType)
return context.symbolTable.declareVariable(
ktDelegate.startOffsetSkippingComments, ktDelegate.endOffset, IrDeclarationOrigin.DELEGATE,
ktDelegate.startOffsetSkippingComments, ktDelegate.endOffset, IrDeclarationOrigin.PROPERTY_DELEGATE,
delegateDescriptor, delegateDescriptor.type.toIrType()
).also { irVariable ->
irVariable.initializer = generateInitializerForLocalDelegatedPropertyDelegate(
@@ -24,7 +24,8 @@ interface IrDeclarationOrigin {
object FOR_LOOP_IMPLICIT_VARIABLE : IrDeclarationOriginImpl("FOR_LOOP_IMPLICIT_VARIABLE")
object PROPERTY_BACKING_FIELD : IrDeclarationOriginImpl("PROPERTY_BACKING_FIELD")
object DEFAULT_PROPERTY_ACCESSOR : IrDeclarationOriginImpl("DEFAULT_PROPERTY_ACCESSOR")
object DELEGATE : IrDeclarationOriginImpl("DELEGATE")
object DELEGATE : IrDeclarationOriginImpl("DELEGATE", isSynthetic = true)
object PROPERTY_DELEGATE : IrDeclarationOriginImpl("PROPERTY_DELEGATE")
object DELEGATED_PROPERTY_ACCESSOR : IrDeclarationOriginImpl("DELEGATED_PROPERTY_ACCESSOR")
object DELEGATED_MEMBER : IrDeclarationOriginImpl("DELEGATED_MEMBER")
object ENUM_CLASS_SPECIAL_MEMBER : IrDeclarationOriginImpl("ENUM_CLASS_SPECIAL_MEMBER")