More annotation generation for declarations with test cases
This commit is contained in:
+36
-29
@@ -47,24 +47,26 @@ interface IrImplementingDelegateDescriptor : IrDelegateDescriptor {
|
||||
abstract class IrDelegateDescriptorBase(
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
name: Name,
|
||||
delegateType: KotlinType
|
||||
) : PropertyDescriptorImpl(
|
||||
containingDeclaration,
|
||||
/* original = */ null,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PRIVATE,
|
||||
/* isVar = */ false,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isActual = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
) {
|
||||
delegateType: KotlinType,
|
||||
annotations: Annotations = Annotations.EMPTY
|
||||
) :
|
||||
PropertyDescriptorImpl(
|
||||
containingDeclaration,
|
||||
/* original = */ null,
|
||||
annotations,
|
||||
Modality.FINAL,
|
||||
Visibilities.PRIVATE,
|
||||
/* isVar = */ false,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isExpect = */ false,
|
||||
/* isActual = */ false,
|
||||
/* isExternal = */ false,
|
||||
/* isDelegated = */ true
|
||||
) {
|
||||
init {
|
||||
val typeParameters: List<TypeParameterDescriptor> = emptyList()
|
||||
val extensionReceiverParameter: ReceiverParameterDescriptor? = null
|
||||
@@ -75,7 +77,7 @@ abstract class IrDelegateDescriptorBase(
|
||||
setType(delegateType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter)
|
||||
}
|
||||
|
||||
override final fun setOutType(outType: KotlinType?) {
|
||||
final override fun setOutType(outType: KotlinType?) {
|
||||
super.setOutType(outType)
|
||||
}
|
||||
|
||||
@@ -97,21 +99,26 @@ class IrPropertyDelegateDescriptorImpl(
|
||||
override val correspondingProperty: PropertyDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val kPropertyType: KotlinType
|
||||
) : IrDelegateDescriptorBase(
|
||||
correspondingProperty.containingDeclaration,
|
||||
getDelegateName(correspondingProperty.name),
|
||||
delegateType
|
||||
), IrPropertyDelegateDescriptor
|
||||
) :
|
||||
IrDelegateDescriptorBase(
|
||||
correspondingProperty.containingDeclaration,
|
||||
getDelegateName(correspondingProperty.name),
|
||||
delegateType,
|
||||
correspondingProperty.annotations
|
||||
),
|
||||
IrPropertyDelegateDescriptor
|
||||
|
||||
class IrImplementingDelegateDescriptorImpl(
|
||||
containingDeclaration: ClassDescriptor,
|
||||
delegateType: KotlinType,
|
||||
override val correspondingSuperType: KotlinType
|
||||
) : IrDelegateDescriptorBase(
|
||||
containingDeclaration,
|
||||
getDelegateName(containingDeclaration, correspondingSuperType),
|
||||
delegateType
|
||||
), IrImplementingDelegateDescriptor
|
||||
) :
|
||||
IrDelegateDescriptorBase(
|
||||
containingDeclaration,
|
||||
getDelegateName(containingDeclaration, correspondingSuperType),
|
||||
delegateType
|
||||
),
|
||||
IrImplementingDelegateDescriptor
|
||||
|
||||
internal fun getDelegateName(name: Name): Name =
|
||||
Name.identifier(name.asString() + "\$delegate")
|
||||
|
||||
@@ -80,7 +80,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
mapPackageFragmentDescriptor(declaration.packageFragmentDescriptor),
|
||||
declaration.fileAnnotations.toMutableList(),
|
||||
declaration.declarations.map { it.transform() }
|
||||
)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
}
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration): IrStatement =
|
||||
throw IllegalArgumentException("Unsupported declaration type: $declaration")
|
||||
@@ -202,6 +204,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
mapDeclarationOrigin(originalTypeParameter.origin),
|
||||
newTypeParameterDescriptor
|
||||
).apply {
|
||||
transformAnnotations(originalTypeParameter)
|
||||
for (i in upperBounds.indices) {
|
||||
val upperBoundClassifier = upperBounds[i].constructor.declarationDescriptor ?: continue
|
||||
val oldSuperClassifierSymbol = originalTypeParameter.superClassifiers[i]
|
||||
@@ -268,7 +271,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry =
|
||||
IrEnumEntryImpl(
|
||||
@@ -277,7 +282,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() {
|
||||
mapEnumEntryDeclaration(declaration.descriptor),
|
||||
declaration.correspondingClass?.transform(),
|
||||
declaration.initializerExpression?.transform()
|
||||
)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
}
|
||||
|
||||
override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrAnonymousInitializer =
|
||||
IrAnonymousInitializerImpl(
|
||||
|
||||
@@ -73,6 +73,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
declaration.fileEntry,
|
||||
symbolRemapper.getDeclaredFile(declaration.symbol)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
fileAnnotations.addAll(declaration.fileAnnotations)
|
||||
declaration.transformDeclarationsTo(this)
|
||||
}
|
||||
@@ -135,7 +136,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
body = declaration.body?.transform()
|
||||
}
|
||||
|
||||
private fun IrDeclaration.transformAnnotations(declaration: IrDeclaration) {
|
||||
private fun IrAnnotationContainer.transformAnnotations(declaration: IrAnnotationContainer) {
|
||||
declaration.annotations.transformTo(annotations)
|
||||
}
|
||||
|
||||
@@ -170,7 +171,9 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
declaration.delegate.transform(),
|
||||
declaration.getter.transform(),
|
||||
declaration.setter?.transform()
|
||||
)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry =
|
||||
IrEnumEntryImpl(
|
||||
@@ -178,6 +181,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredEnumEntry(declaration.symbol)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
correspondingClass = declaration.correspondingClass?.transform()
|
||||
initializerExpression = declaration.initializerExpression?.transform()
|
||||
}
|
||||
@@ -207,6 +211,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper)
|
||||
mapDeclarationOrigin(declaration.origin),
|
||||
symbolRemapper.getDeclaredTypeParameter(declaration.symbol)
|
||||
).apply {
|
||||
transformAnnotations(declaration)
|
||||
declaration.superClassifiers.mapTo(superClassifiers) {
|
||||
symbolRemapper.getReferencedClassifier(it)
|
||||
}
|
||||
|
||||
@@ -78,6 +78,7 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor<Unit, String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
dumpAnnotations(declaration)
|
||||
declaration.declarations.dumpElements()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user