diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt index 33a44dd60fd..3fde52bed99 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/Psi2IrTranslator.kt @@ -21,8 +21,10 @@ import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.util.patchDeclarationParents import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi2ir.transformations.AnnotationGenerator import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext import org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator +import org.jetbrains.kotlin.psi2ir.transformations.generateAnnotationsForDeclarations import org.jetbrains.kotlin.psi2ir.transformations.insertImplicitCasts import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.utils.SmartList @@ -56,6 +58,7 @@ class Psi2IrTranslator(val configuration: Psi2IrConfiguration = Psi2IrConfigurat private fun postprocess(context: GeneratorContext, irElement: IrElement) { insertImplicitCasts(context.builtIns, irElement, context.symbolTable) + generateAnnotationsForDeclarations(context, irElement) postprocessingSteps.forEach { it.postprocess(context, irElement) } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ConstantValueGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ConstantValueGenerator.kt new file mode 100644 index 00000000000..3827075929b --- /dev/null +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ConstantValueGenerator.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.generators + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl +import org.jetbrains.kotlin.psi2ir.transformations.AnnotationGenerator +import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.typeUtil.builtIns + +class ConstantValueGenerator( + private val context: GeneratorContext, + private val annotationGenerator: AnnotationGenerator? = null +) { + + fun generateConstantValueAsExpression( + startOffset: Int, + endOffset: Int, + constantValue: ConstantValue<*>, + varargElementType: KotlinType? = null + ): IrExpression { + val constantType = constantValue.getType(context.moduleDescriptor) + + return when (constantValue) { + is StringValue -> IrConstImpl.string(startOffset, endOffset, constantType, constantValue.value) + is IntValue -> IrConstImpl.int(startOffset, endOffset, constantType, constantValue.value) + is NullValue -> IrConstImpl.constNull(startOffset, endOffset, constantType) + is BooleanValue -> IrConstImpl.boolean(startOffset, endOffset, constantType, constantValue.value) + is LongValue -> IrConstImpl.long(startOffset, endOffset, constantType, constantValue.value) + is DoubleValue -> IrConstImpl.double(startOffset, endOffset, constantType, constantValue.value) + is FloatValue -> IrConstImpl.float(startOffset, endOffset, constantType, constantValue.value) + is CharValue -> IrConstImpl.char(startOffset, endOffset, constantType, constantValue.value) + is ByteValue -> IrConstImpl.byte(startOffset, endOffset, constantType, constantValue.value) + is ShortValue -> IrConstImpl.short(startOffset, endOffset, constantType, constantValue.value) + + is ArrayValue -> { + val arrayElementType = varargElementType ?: constantType.getArrayElementType() + IrVarargImpl( + startOffset, endOffset, + constantType, + arrayElementType, + constantValue.value.map { + generateConstantValueAsExpression(startOffset, endOffset, it, null) + } + ) + } + + is EnumValue -> { + val enumEntryDescriptor = + constantType.memberScope.getContributedClassifier(constantValue.enumEntryName, NoLookupLocation.FROM_BACKEND) + ?: throw AssertionError("No such enum entry ${constantValue.enumEntryName} in $constantType") + if (enumEntryDescriptor !is ClassDescriptor) { + throw AssertionError("Enum entry $enumEntryDescriptor should be a ClassDescriptor") + } + IrGetEnumValueImpl( + startOffset, endOffset, + constantType, + context.symbolTable.referenceEnumEntry(enumEntryDescriptor) + ) + } + + is AnnotationValue -> { + if (annotationGenerator == null) throw AssertionError("Unexpected AnnotationValue: $constantValue") + annotationGenerator.generateAnnotationConstructorCall(constantValue.value) + } + + else -> TODO("handle other literal values: ${constantValue::class.simpleName}") + } + } + + private fun KotlinType.getArrayElementType() = builtIns.getArrayElementType(this) +} \ No newline at end of file diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt index 2a007e971f4..c073d07c9ee 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/FunctionGenerator.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils class FunctionGenerator(declarationGenerator: DeclarationGenerator) : DeclarationGeneratorExtension(declarationGenerator) { + constructor(context: GeneratorContext) : this(DeclarationGenerator(context)) fun generateFunctionDeclaration(ktFunction: KtNamedFunction): IrFunction = diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt index 6866d42f3da..a9315563dc4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt @@ -39,7 +39,7 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.BindingContextUtils import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall -import org.jetbrains.kotlin.resolve.constants.* +import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils import java.lang.AssertionError @@ -205,35 +205,12 @@ class StatementGenerator( ?: error("KtConstantExpression was not evaluated: ${expression.text}") ) - fun generateConstantExpression(expression: KtExpression, constant: CompileTimeConstant<*>): IrExpression { - val constantValue = constant.toConstantValue(getInferredTypeWithImplicitCastsOrFail(expression)) - val constantType = constantValue.getType(context.moduleDescriptor) - - return when (constantValue) { - is StringValue -> - IrConstImpl.string(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is IntValue -> - IrConstImpl.int(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is NullValue -> - IrConstImpl.constNull(expression.startOffset, expression.endOffset, constantType) - is BooleanValue -> - IrConstImpl.boolean(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is LongValue -> - IrConstImpl.long(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is DoubleValue -> - IrConstImpl.double(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is FloatValue -> - IrConstImpl.float(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is CharValue -> - IrConstImpl.char(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is ByteValue -> - IrConstImpl.byte(expression.startOffset, expression.endOffset, constantType, constantValue.value) - is ShortValue -> - IrConstImpl.short(expression.startOffset, expression.endOffset, constantType, constantValue.value) - else -> - TODO("handle other literal types: $constantType") - } - } + fun generateConstantExpression(expression: KtExpression, constant: CompileTimeConstant<*>): IrExpression = + ConstantValueGenerator(context).generateConstantValueAsExpression( + expression.startOffset, + expression.endOffset, + constant.toConstantValue(getInferredTypeWithImplicitCastsOrFail(expression)) + ) override fun visitStringTemplateExpression(expression: KtStringTemplateExpression, data: Nothing?): IrStatement { val entries = expression.entries diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/AnnotationGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/AnnotationGenerator.kt new file mode 100644 index 00000000000..d25a9747e38 --- /dev/null +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/AnnotationGenerator.kt @@ -0,0 +1,117 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.psi2ir.transformations + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.PropertyGetterDescriptor +import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET +import org.jetbrains.kotlin.ir.declarations.IrDeclaration +import org.jetbrains.kotlin.ir.declarations.IrField +import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.expressions.IrExpression +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid +import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid +import org.jetbrains.kotlin.ir.visitors.acceptVoid +import org.jetbrains.kotlin.psi.psiUtil.startOffset +import org.jetbrains.kotlin.psi2ir.generators.ConstantValueGenerator +import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.source.PsiSourceElement +import org.jetbrains.kotlin.utils.addToStdlib.safeAs + +fun generateAnnotationsForDeclarations(context: GeneratorContext, irElement: IrElement) { + irElement.acceptVoid(AnnotationGenerator(context)) +} + +class AnnotationGenerator(private val context: GeneratorContext) : IrElementVisitorVoid { + + private val constantValueGenerator = ConstantValueGenerator(context, this) + + override fun visitElement(element: IrElement) { + element.acceptChildrenVoid(this) + } + + override fun visitDeclaration(declaration: IrDeclaration) { + visitElement(declaration) + generateAnnotationsForDeclaration(declaration) + } + + private fun generateAnnotationsForDeclaration(declaration: IrDeclaration) { + val allAnnotations = declaration.descriptor.annotations.getAllAnnotations() + val matchingAnnotations = allAnnotations.filter { + isAnnotationTargetMatchingDeclaration(it.target, declaration) + } + matchingAnnotations.mapTo(declaration.annotations) { + generateAnnotationConstructorCall(it.annotation) + } + } + + fun generateAnnotationConstructorCall(annotationDescriptor: AnnotationDescriptor): IrExpression { + val annotationType = annotationDescriptor.type + val annotationClassDescriptor = annotationType.constructor.declarationDescriptor + ?: throw AssertionError("No declaration descriptor for annotation $annotationDescriptor") + assert(DescriptorUtils.isAnnotationClass(annotationClassDescriptor)) { + "Annotation class expected: $annotationClassDescriptor" + } + + val primaryConstructorDescriptor = + annotationClassDescriptor.safeAs()?.unsubstitutedPrimaryConstructor + ?: throw AssertionError("No primary constructor for annotation class $annotationClassDescriptor") + val primaryConstructorSymbol = context.symbolTable.referenceConstructor(primaryConstructorDescriptor) + + val psi = annotationDescriptor.source.safeAs()?.psi + val startOffset = psi?.startOffset ?: UNDEFINED_OFFSET + val endOffset = psi?.startOffset ?: UNDEFINED_OFFSET + + val irCall = IrCallImpl( + startOffset, endOffset, annotationType, + primaryConstructorSymbol, primaryConstructorDescriptor, + typeArgumentsCount = 0 + ) + + for (valueParameter in primaryConstructorDescriptor.valueParameters) { + val argumentIndex = valueParameter.index + val argumentValue = annotationDescriptor.allValueArguments[valueParameter.name] + ?: throw AssertionError("Annotation $annotationDescriptor missing value argument for $valueParameter") + val irArgument = + constantValueGenerator.generateConstantValueAsExpression( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + argumentValue, + valueParameter.varargElementType + ) + irCall.putValueArgument(argumentIndex, irArgument) + } + + return irCall + } + + private fun isAnnotationTargetMatchingDeclaration(target: AnnotationUseSiteTarget?, element: IrElement): Boolean = + when (element) { + is IrProperty -> target == null || target == AnnotationUseSiteTarget.PROPERTY + + is IrField -> target == AnnotationUseSiteTarget.FIELD + + is IrSimpleFunction -> + target == null || element.descriptor.let { + when (it) { + is PropertyGetterDescriptor -> target == AnnotationUseSiteTarget.PROPERTY_GETTER + is PropertySetterDescriptor -> target == AnnotationUseSiteTarget.PROPERTY_SETTER + else -> false + } + } + + else -> target == null + } +} + + diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt index b9d574eb8d6..01795fc4fce 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTree.kt @@ -92,6 +92,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapClassDeclaration(declaration.descriptor), declaration.declarations.map { it.transform() } ).apply { + transformAnnotations(declaration) thisReceiver = declaration.thisReceiver?.withDescriptor(descriptor.thisAsReceiverParameter) transformTypeParameters(declaration, descriptor.declaredTypeParameters) @@ -117,7 +118,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { declaration.startOffset, declaration.endOffset, mapDeclarationOrigin(declaration.origin), mapTypeAliasDeclaration(declaration.descriptor) - ) + ).apply { + transformAnnotations(declaration) + } override fun visitSimpleFunction(declaration: IrSimpleFunction): IrFunction = IrFunctionImpl( @@ -126,6 +129,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapFunctionDeclaration(declaration.descriptor), declaration.body?.transform() ).transformParameters(declaration).apply { + transformAnnotations(declaration) descriptor.overriddenDescriptors.mapIndexedTo(overriddenSymbols) { index, overriddenDescriptor -> val oldOverriddenSymbol = declaration.overriddenSymbols.getOrNull(index) if (overriddenDescriptor.original == oldOverriddenSymbol?.descriptor?.original) @@ -141,7 +145,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapDeclarationOrigin(declaration.origin), mapConstructorDeclaration(declaration.descriptor), declaration.body?.transform() - ).transformParameters(declaration) + ).transformParameters(declaration).apply { + transformAnnotations(declaration) + } protected fun T.transformTypeParameters( original: T, @@ -183,6 +189,10 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { } } + private fun IrAnnotationContainer.transformAnnotations(original: IrAnnotationContainer) { + original.annotations.mapTo(annotations) { it.transform() } + } + protected fun copyTypeParameter( originalTypeParameter: IrTypeParameter, newTypeParameterDescriptor: TypeParameterDescriptor @@ -220,7 +230,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapDeclarationOrigin(originalValueParameter.origin), newParameterDescriptor, originalValueParameter.defaultValue?.transform() - ) + ).apply { + transformAnnotations(originalValueParameter) + } // TODO visitTypeParameter // TODO visitValueParameter @@ -234,7 +246,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { declaration.backingField?.transform(), declaration.getter?.transform(), declaration.setter?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitField(declaration: IrField): IrField = IrFieldImpl( @@ -242,7 +256,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapDeclarationOrigin(declaration.origin), mapPropertyDeclaration(declaration.descriptor), declaration.initializer?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitLocalDelegatedProperty(declaration: IrLocalDelegatedProperty): IrLocalDelegatedProperty = IrLocalDelegatedPropertyImpl( @@ -277,7 +293,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapDeclarationOrigin(declaration.origin), mapVariableDeclaration(declaration.descriptor), declaration.initializer?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitBody(body: IrBody): IrBody = throw IllegalArgumentException("Unsupported body type: $body") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt index 9aae353af6b..f615b648e55 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt @@ -86,6 +86,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredClass(declaration.symbol) ).apply { + transformAnnotations(declaration) declaration.superClasses.mapTo(superClasses) { symbolRemapper.getReferencedClass(it) } @@ -99,7 +100,9 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) declaration.startOffset, declaration.endOffset, mapDeclarationOrigin(declaration.origin), declaration.descriptor - ) + ).apply { + transformAnnotations(declaration) + } override fun visitSimpleFunction(declaration: IrSimpleFunction): IrSimpleFunction = IrFunctionImpl( @@ -124,6 +127,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) private fun T.transformFunctionChildren(declaration: T): T = apply { + transformAnnotations(declaration) declaration.typeParameters.transformTo(typeParameters) dispatchReceiverParameter = declaration.dispatchReceiverParameter?.transform() extensionReceiverParameter = declaration.extensionReceiverParameter?.transform() @@ -131,6 +135,10 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) body = declaration.body?.transform() } + private fun IrDeclaration.transformAnnotations(declaration: IrDeclaration) { + declaration.annotations.transformTo(annotations) + } + override fun visitProperty(declaration: IrProperty): IrProperty = IrPropertyImpl( declaration.startOffset, declaration.endOffset, @@ -140,7 +148,9 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) declaration.backingField?.transform(), declaration.getter?.transform(), declaration.setter?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitField(declaration: IrField): IrField = IrFieldImpl( @@ -148,6 +158,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredField(declaration.symbol) ).apply { + transformAnnotations(declaration) initializer = declaration.initializer?.transform() } @@ -186,6 +197,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredVariable(declaration.symbol) ).apply { + transformAnnotations(declaration) initializer = declaration.initializer?.transform() } @@ -206,6 +218,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredValueParameter(declaration.symbol) ).apply { + transformAnnotations(declaration) defaultValue = declaration.defaultValue?.transform() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt index 17bb3553d8b..5e4bbc57f1c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt @@ -53,7 +53,12 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { } override fun visitElement(element: IrElement, data: String) { - element.dumpLabeledSubTree(data) + element.dumpLabeledElementWith(data) { + if (element is IrAnnotationContainer) { + dumpAnnotations(element) + } + element.acceptChildren(this@DumpIrTreeVisitor, "") + } } override fun visitModuleFragment(declaration: IrModuleFragment, data: String) { @@ -79,6 +84,7 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { override fun visitClass(declaration: IrClass, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.thisReceiver?.accept(this, "\$this") declaration.superClasses.renderDeclarationElementsOrDescriptors("superClasses") declaration.typeParameters.dumpElements() @@ -88,12 +94,14 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { override fun visitTypeParameter(declaration: IrTypeParameter, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.superClassifiers.renderDeclarationElementsOrDescriptors("superClassifiers") } } override fun visitSimpleFunction(declaration: IrSimpleFunction, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.overriddenSymbols.renderDeclarationElementsOrDescriptors("overridden") declaration.typeParameters.dumpElements() declaration.dispatchReceiverParameter?.accept(this, "\$this") @@ -103,6 +111,14 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { } } + private fun dumpAnnotations(element: IrAnnotationContainer) { + if (element.annotations.isNotEmpty()) { + indented("annotations") { + element.annotations.dumpElements() + } + } + } + private fun Collection.renderDeclarationElementsOrDescriptors(caption: String) { if (isNotEmpty()) { indented(caption) { @@ -114,19 +130,19 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { } private fun IrSymbol.renderDeclarationElementOrDescriptor(label: String? = null) { - if (isBound) - owner.render(label) - else { - if (label != null) { + when { + isBound -> + owner.render(label) + label != null -> printer.println("$label: ", "UNBOUND: ", DescriptorRenderer.COMPACT.render(descriptor)) - } else { + else -> printer.println("UNBOUND: ", DescriptorRenderer.COMPACT.render(descriptor)) - } } } override fun visitConstructor(declaration: IrConstructor, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.typeParameters.dumpElements() declaration.dispatchReceiverParameter?.accept(this, "\$outer") declaration.valueParameters.dumpElements() @@ -136,6 +152,7 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { override fun visitProperty(declaration: IrProperty, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.typeParameters.dumpElements() declaration.backingField?.accept(this, "") declaration.getter?.accept(this, "") @@ -156,6 +173,7 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { override fun visitEnumEntry(declaration: IrEnumEntry, data: String) { declaration.dumpLabeledElementWith(data) { + dumpAnnotations(declaration) declaration.initializerExpression?.accept(this, "init") declaration.correspondingClass?.accept(this, "class") } diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt new file mode 100644 index 00000000000..8856a65604e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt @@ -0,0 +1,7 @@ +annotation class A1(val x: Int) +annotation class A2(val a: A1) +annotation class AA(val xs: Array) + +@A2(A1(42)) +@AA([A1(1), A1(2)]) +fun test() {} diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.txt new file mode 100644 index 00000000000..cd6bb6efd87 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.txt @@ -0,0 +1,100 @@ +FILE fqName: fileName:/annotationsInAnnotationArguments.kt + CLASS ANNOTATION_CLASS name:A1 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A1 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:A1 flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + PROPERTY name:x type:kotlin.Int visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:A1) returnType:Int flags: + $this: VALUE_PARAMETER name: type:A1 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@A1: A1' type=A1 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ANNOTATION_CLASS name:A2 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A2 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (a:A1) returnType:A2 flags: + VALUE_PARAMETER name:a index:0 type:A1 flags: + PROPERTY name:a type:A1 visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:a type:A1 visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter a: A1' type=A1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:A2) returnType:A1 flags: + $this: VALUE_PARAMETER name: type:A2 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): A1' + GET_FIELD 'a: A1' type=A1 origin=null + receiver: GET_VAR 'this@A2: A2' type=A2 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ANNOTATION_CLASS name:AA modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:AA flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:AA flags: + VALUE_PARAMETER name:xs index:0 type:kotlin.Array flags: + PROPERTY name:xs type:kotlin.Array visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter xs: Array' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:AA) returnType:Array flags: + $this: VALUE_PARAMETER name: type:AA flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'xs: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@AA: AA' type=AA origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:test visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A2(A1)' type=A2 origin=null + a: CALL 'constructor A1(Int)' type=A1 origin=null + x: CONST Int type=kotlin.Int value=42 + CALL 'constructor AA(Array)' type=AA origin=null + xs: VARARG type=Array varargElementType=A1 + CALL 'constructor A1(Int)' type=A1 origin=null + x: CONST Int type=kotlin.Int value=1 + CALL 'constructor A1(Int)' type=A1 origin=null + x: CONST Int type=kotlin.Int value=2 + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt new file mode 100644 index 00000000000..3891bbe5403 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt @@ -0,0 +1,10 @@ +annotation class TestAnnWithIntArray(val x: IntArray) +annotation class TestAnnWithStringArray(val x: Array) + +@TestAnnWithIntArray(intArrayOf(1, 2, 3)) +@TestAnnWithStringArray(arrayOf("a", "b", "c")) +fun test1() {} + +@TestAnnWithIntArray([4, 5, 6]) +@TestAnnWithStringArray(["d", "e", "f"]) +fun test2() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.txt new file mode 100644 index 00000000000..46f919bf6aa --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.txt @@ -0,0 +1,85 @@ +FILE fqName: fileName:/arrayInAnnotationArguments.kt + CLASS ANNOTATION_CLASS name:TestAnnWithIntArray modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnnWithIntArray flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.IntArray) returnType:TestAnnWithIntArray flags: + VALUE_PARAMETER name:x index:0 type:kotlin.IntArray flags: + PROPERTY name:x type:kotlin.IntArray visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.IntArray visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: IntArray' type=kotlin.IntArray origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnnWithIntArray) returnType:IntArray flags: + $this: VALUE_PARAMETER name: type:TestAnnWithIntArray flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): IntArray' + GET_FIELD 'x: IntArray' type=kotlin.IntArray origin=null + receiver: GET_VAR 'this@TestAnnWithIntArray: TestAnnWithIntArray' type=TestAnnWithIntArray origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ANNOTATION_CLASS name:TestAnnWithStringArray modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnnWithStringArray flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Array) returnType:TestAnnWithStringArray flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Array flags: + PROPERTY name:x type:kotlin.Array visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Array visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: Array' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnnWithStringArray) returnType:Array flags: + $this: VALUE_PARAMETER name: type:TestAnnWithStringArray flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'x: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@TestAnnWithStringArray: TestAnnWithStringArray' type=TestAnnWithStringArray origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:test1 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor TestAnnWithIntArray(IntArray)' type=TestAnnWithIntArray origin=null + x: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=3 + CALL 'constructor TestAnnWithStringArray(Array)' type=TestAnnWithStringArray origin=null + x: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=a + CONST String type=kotlin.String value=b + CONST String type=kotlin.String value=c + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor TestAnnWithIntArray(IntArray)' type=TestAnnWithIntArray origin=null + x: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=4 + CONST Int type=kotlin.Int value=5 + CONST Int type=kotlin.Int value=6 + CALL 'constructor TestAnnWithStringArray(Array)' type=TestAnnWithStringArray origin=null + x: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=d + CONST String type=kotlin.String value=e + CONST String type=kotlin.String value=f + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt new file mode 100644 index 00000000000..b588831f780 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt @@ -0,0 +1,21 @@ +annotation class TestAnn(val x: String) + +@TestAnn("class") +class TestClass + +@TestAnn("interface") +interface TestInterface + +@TestAnn("object") +object TestObject + +class Host { + @TestAnn("companion") + companion object TestCompanion +} + +@TestAnn("enum") +enum class TestEnum + +@TestAnn("annotation") +annotation class TestAnnotation \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.txt new file mode 100644 index 00000000000..f5e76747c81 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.txt @@ -0,0 +1,221 @@ +FILE fqName: fileName:/classesWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS CLASS name:TestClass modality:FINAL visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=class + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestClass flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:TestClass flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='TestClass' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS INTERFACE name:TestInterface modality:ABSTRACT visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=interface + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestInterface flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS OBJECT name:TestObject modality:FINAL visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=object + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestObject flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:private <> () returnType:TestObject flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='TestObject' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS CLASS name:Host modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Host flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:Host flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='Host' + CLASS OBJECT name:TestCompanion modality:FINAL visibility:public flags:companion + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=companion + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Host.TestCompanion flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:private <> () returnType:Host.TestCompanion flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='companion object of HostTestCompanion' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ENUM_CLASS name:TestEnum modality:FINAL visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=enum + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestEnum flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Enum modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:private <> () returnType:TestEnum flags: + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' + >: TestEnum + INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum' + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:Any flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:Any flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum) returnType:Unit flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum) returnType:Unit flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:(java.lang.Class<(TestEnum..TestEnum?)>..java.lang.Class<(TestEnum..TestEnum?)>?) flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:(java.lang.Class<(E..E?)>..java.lang.Class<(E..E?)>?) flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:TestEnum) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:E) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + VALUE_PARAMETER name:other index:0 type:TestEnum flags: + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + PROPERTY FAKE_OVERRIDE name:name type:kotlin.String visibility:public modality:FINAL flags:val + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + PROPERTY FAKE_OVERRIDE name:ordinal type:kotlin.Int visibility:public modality:FINAL flags:val + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:Array flags: + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:TestEnum flags: + VALUE_PARAMETER name:value index:0 type:kotlin.String flags: + SYNTHETIC_BODY kind=ENUM_VALUEOF + CLASS ANNOTATION_CLASS name:TestAnnotation modality:FINAL visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=annotation + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnnotation flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:TestAnnotation flags: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: diff --git a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt new file mode 100644 index 00000000000..aecb53bec18 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt @@ -0,0 +1,5 @@ +annotation class TestAnn(val x: Int) + +class TestClass @TestAnn(1) constructor() { + @TestAnn(2) constructor(x: Int) : this() +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.txt new file mode 100644 index 00000000000..94f22b89f8b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.txt @@ -0,0 +1,61 @@ +FILE fqName: fileName:/constructorsWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + PROPERTY name:x type:kotlin.Int visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:Int flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS CLASS name:TestClass modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestClass flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:TestClass flags: + annotations: + CALL 'constructor TestAnn(Int)' type=TestAnn origin=null + x: CONST Int type=kotlin.Int value=1 + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='TestClass' + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:TestClass flags: + annotations: + CALL 'constructor TestAnn(Int)' type=TestAnn origin=null + x: CONST Int type=kotlin.Int value=2 + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor TestClass()' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: diff --git a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt new file mode 100644 index 00000000000..15e2c12e605 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt @@ -0,0 +1,6 @@ +enum class En { A, B, C, D } + +annotation class TestAnn(val x: En) + +@TestAnn(En.A) +fun test1() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.txt new file mode 100644 index 00000000000..11b7340913c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.txt @@ -0,0 +1,97 @@ +FILE fqName: fileName:/enumsInAnnotationArguments.kt + CLASS ENUM_CLASS name:En modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:En flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Enum modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:private <> () returnType:En flags: + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' + >: En + INSTANCE_INITIALIZER_CALL classDescriptor='En' + ENUM_ENTRY name:A + init: ENUM_CONSTRUCTOR_CALL 'constructor En()' + ENUM_ENTRY name:B + init: ENUM_CONSTRUCTOR_CALL 'constructor En()' + ENUM_ENTRY name:C + init: ENUM_CONSTRUCTOR_CALL 'constructor En()' + ENUM_ENTRY name:D + init: ENUM_CONSTRUCTOR_CALL 'constructor En()' + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:Any flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:Any flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum) returnType:Unit flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum) returnType:Unit flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:(java.lang.Class<(En..En?)>..java.lang.Class<(En..En?)>?) flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:(java.lang.Class<(E..E?)>..java.lang.Class<(E..E?)>?) flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:En) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:E) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + VALUE_PARAMETER name:other index:0 type:En flags: + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + PROPERTY FAKE_OVERRIDE name:name type:kotlin.String visibility:public modality:FINAL flags:val + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + PROPERTY FAKE_OVERRIDE name:ordinal type:kotlin.Int visibility:public modality:FINAL flags:val + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name: visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:Array flags: + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:En flags: + VALUE_PARAMETER name:value index:0 type:kotlin.String flags: + SYNTHETIC_BODY kind=ENUM_VALUEOF + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:En) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:En flags: + PROPERTY name:x type:En visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:En visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: En' type=En origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:En flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): En' + GET_FIELD 'x: En' type=En origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:test1 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor TestAnn(En)' type=TestAnn origin=null + x: GET_ENUM 'A' type=En + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt new file mode 100644 index 00000000000..fb5312cb742 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt @@ -0,0 +1,7 @@ +annotation class TestAnn(val x: String) + +@field:TestAnn("testVal.field") +val testVal = "a val" + +@field:TestAnn("testVar.field") +var testVar = "a var" \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.txt new file mode 100644 index 00000000000..e2be6eee477 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.txt @@ -0,0 +1,57 @@ +FILE fqName: fileName:/fieldsWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + PROPERTY name:testVal type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:public + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=testVal.field + EXPRESSION_BODY + CONST String type=kotlin.String value=a val + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:String flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'testVal: String' type=kotlin.String origin=null + PROPERTY name:testVar type:kotlin.String visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:testVar type:kotlin.String visibility:public + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=testVar.field + EXPRESSION_BODY + CONST String type=kotlin.String value=a var + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:String flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'testVar: String' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:Unit flags: + VALUE_PARAMETER name: index:0 type:kotlin.String flags: + BLOCK_BODY + SET_FIELD 'testVar: String' type=kotlin.Unit origin=null + value: GET_VAR 'value-parameter : String' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt new file mode 100644 index 00000000000..f9dd83e72b9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt @@ -0,0 +1,3 @@ +annotation class TestAnn(val x: Int) + +@TestAnn(42) fun testSimpleFunction() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.txt new file mode 100644 index 00000000000..acd69f168c0 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/functionsWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + PROPERTY name:x type:kotlin.Int visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:Int flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:testSimpleFunction visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor TestAnn(Int)' type=TestAnn origin=null + x: CONST Int type=kotlin.Int value=42 + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt new file mode 100644 index 00000000000..26aaa52951a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt @@ -0,0 +1,4 @@ +annotation class TestAnn(val x: String) + +@TestAnn("testVal.property") +val testVal: String = "" \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.txt new file mode 100644 index 00000000000..6aedf52172e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.txt @@ -0,0 +1,41 @@ +FILE fqName: fileName:/propertiesWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + PROPERTY name:testVal type:kotlin.String visibility:public modality:FINAL flags:val + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=testVal.property + FIELD PROPERTY_BACKING_FIELD name:testVal type:kotlin.String visibility:public + EXPRESSION_BODY + CONST String type=kotlin.String value= + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:String flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'testVal: String' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt new file mode 100644 index 00000000000..0bef9dfbb0c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt @@ -0,0 +1,15 @@ +annotation class TestAnn(val x: String) + +val test1: String + @TestAnn("test1.get") get() = "" + +var test2: String + @TestAnn("test2.get") get() = "" + @TestAnn("test2.set") set(value) {} + +@get:TestAnn("test3.get") +val test3: String = "" + +@get:TestAnn("test4.get") +@set:TestAnn("test4.set") +var test4: String = "" \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.txt new file mode 100644 index 00000000000..ddc52db19d3 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.txt @@ -0,0 +1,82 @@ +FILE fqName: fileName:/propertyAccessorsWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + PROPERTY name:test1 type:kotlin.String visibility:public modality:FINAL flags:val + FUN name: visibility:public modality:FINAL <> () returnType:String flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test1.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + CONST String type=kotlin.String value= + PROPERTY name:test2 type:kotlin.String visibility:public modality:FINAL flags:var + FUN name: visibility:public modality:FINAL <> () returnType:String flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test2.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + CONST String type=kotlin.String value= + FUN name: visibility:public modality:FINAL <> (value:kotlin.String) returnType:Unit flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test2.set + VALUE_PARAMETER name:value index:0 type:kotlin.String flags: + BLOCK_BODY + PROPERTY name:test3 type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.String visibility:public + EXPRESSION_BODY + CONST String type=kotlin.String value= + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:String flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test3.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'test3: String' type=kotlin.String origin=null + PROPERTY name:test4 type:kotlin.String visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.String visibility:public + EXPRESSION_BODY + CONST String type=kotlin.String value= + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:String flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test4.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'test4: String' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:Unit flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=test4.set + VALUE_PARAMETER name: index:0 type:kotlin.String flags: + BLOCK_BODY + SET_FIELD 'test4: String' type=kotlin.Unit origin=null + value: GET_VAR 'value-parameter : String' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt new file mode 100644 index 00000000000..9a9220cc5ad --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt @@ -0,0 +1,5 @@ +@Target(AnnotationTarget.TYPEALIAS) +annotation class TestAnn(val x: String) + +@TestAnn("TestTypeAlias") +typealias TestTypeAlias = String \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.txt new file mode 100644 index 00000000000..34994157909 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.txt @@ -0,0 +1,38 @@ +FILE fqName: fileName:/typeAliasesWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + annotations: + CALL 'constructor Target(vararg AnnotationTarget)' type=kotlin.annotation.Target origin=null + allowedTargets: VARARG type=Array varargElementType=AnnotationTarget + GET_ENUM 'TYPEALIAS' type=kotlin.annotation.AnnotationTarget + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + TYPEALIAS typealias TestTypeAlias = String type=kotlin.String + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=TestTypeAlias diff --git a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt new file mode 100644 index 00000000000..93bd42aee37 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt @@ -0,0 +1,7 @@ +annotation class TestAnn(val x: String) + +fun testFun(@TestAnn("testFun.x") x: Int) {} + +class TestClassConstructor1(@TestAnn("TestClassConstructor1.x")x: Int) { + val xx = x +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.txt new file mode 100644 index 00000000000..ffe90d212b0 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.txt @@ -0,0 +1,71 @@ +FILE fqName: fileName:/valueParametersWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:testFun visibility:public modality:FINAL <> (x:kotlin.Int) returnType:Unit flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=testFun.x + BLOCK_BODY + CLASS CLASS name:TestClassConstructor1 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestClassConstructor1 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:TestClassConstructor1 flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=TestClassConstructor1.x + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='TestClassConstructor1' + PROPERTY name:xx type:kotlin.Int visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:xx type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestClassConstructor1) returnType:Int flags: + $this: VALUE_PARAMETER name: type:TestClassConstructor1 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'xx: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@TestClassConstructor1: TestClassConstructor1' type=TestClassConstructor1 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN IR_EXTERNAL_DECLARATION_STUB name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: diff --git a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt new file mode 100644 index 00000000000..883bb290868 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt @@ -0,0 +1,13 @@ +annotation class A1(vararg val xs: Int) +annotation class A2(vararg val xs: String) +annotation class AA(vararg val xs: A1) + +@A1(1, 2, 3) +@A2("a", "b", "c") +@AA(A1(4), A1(5), A1(6)) +fun test1() {} + +@A1() +@A2() +@AA() +fun test2() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.txt new file mode 100644 index 00000000000..fd691e21c79 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.txt @@ -0,0 +1,121 @@ +FILE fqName: fileName:/varargsInAnnotationArguments.kt + CLASS ANNOTATION_CLASS name:A1 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A1 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.IntArray) returnType:A1 flags: + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int flags:vararg + PROPERTY name:xs type:kotlin.IntArray visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.IntArray visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter vararg xs: Int' type=kotlin.IntArray origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:A1) returnType:IntArray flags: + $this: VALUE_PARAMETER name: type:A1 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): IntArray' + GET_FIELD 'xs: IntArray' type=kotlin.IntArray origin=null + receiver: GET_VAR 'this@A1: A1' type=A1 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ANNOTATION_CLASS name:A2 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A2 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:A2 flags: + VALUE_PARAMETER name:xs index:0 type:kotlin.Array varargElementType:kotlin.String flags:vararg + PROPERTY name:xs type:kotlin.Array visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter vararg xs: String' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:A2) returnType:Array flags: + $this: VALUE_PARAMETER name: type:A2 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'xs: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@A2: A2' type=A2 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + CLASS ANNOTATION_CLASS name:AA modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:AA flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:AA flags: + VALUE_PARAMETER name:xs index:0 type:kotlin.Array varargElementType:A1 flags:vararg + PROPERTY name:xs type:kotlin.Array visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter vararg xs: A1' type=kotlin.Array origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:AA) returnType:Array flags: + $this: VALUE_PARAMETER name: type:AA flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'xs: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@AA: AA' type=AA origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:test1 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A1(vararg Int)' type=A1 origin=null + xs: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=3 + CALL 'constructor A2(vararg String)' type=A2 origin=null + xs: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=a + CONST String type=kotlin.String value=b + CONST String type=kotlin.String value=c + CALL 'constructor AA(vararg A1)' type=AA origin=null + xs: VARARG type=Array varargElementType=A1 + CALL 'constructor A1(vararg Int)' type=A1 origin=null + xs: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=4 + CALL 'constructor A1(vararg Int)' type=A1 origin=null + xs: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=5 + CALL 'constructor A1(vararg Int)' type=A1 origin=null + xs: VARARG type=IntArray varargElementType=Int + CONST Int type=kotlin.Int value=6 + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A1(vararg Int)' type=A1 origin=null + xs: VARARG type=IntArray varargElementType=Int + CALL 'constructor A2(vararg String)' type=A2 origin=null + xs: VARARG type=Array varargElementType=String + CALL 'constructor AA(vararg A1)' type=AA origin=null + xs: VARARG type=Array varargElementType=A1 + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt new file mode 100644 index 00000000000..79507bb1d90 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt @@ -0,0 +1,9 @@ +annotation class TestAnn(val x: String) + +fun foo() { + @TestAnn("foo/testVal") + val testVal = "testVal" + + @TestAnn("foo/testVar") + var testVar = "testVar" +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.txt new file mode 100644 index 00000000000..9f17a53f671 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.txt @@ -0,0 +1,42 @@ +FILE fqName: fileName:/variablesWithAnnotations.kt + CLASS ANNOTATION_CLASS name:TestAnn modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestAnn flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:TestAnn flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + PROPERTY name:x type:kotlin.String visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter x: String' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestAnn) returnType:String flags: + $this: VALUE_PARAMETER name: type:TestAnn flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@TestAnn: TestAnn' type=TestAnn origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + overridden: + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:Boolean flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + VALUE_PARAMETER name:other index:0 type:kotlin.Any? flags: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + overridden: + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:Int flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + overridden: + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Any flags: + FUN name:foo visibility:public modality:FINAL <> () returnType:Unit flags: + BLOCK_BODY + VAR name:testVal type:kotlin.String flags:val + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=foo/testVal + CONST String type=kotlin.String value=testVal + VAR name:testVar type:kotlin.String flags:var + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=foo/testVar + CONST String type=kotlin.String value=testVar diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index bb03bd5cc60..73c61a8a5e3 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -330,6 +330,93 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("compiler/testData/ir/irText/declarations/annotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Annotations extends AbstractIrTextTestCase { + public void testAllFilesPresentInAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/declarations/annotations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("annotationsInAnnotationArguments.kt") + public void testAnnotationsInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/annotationsInAnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("arrayInAnnotationArguments.kt") + public void testArrayInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("classesWithAnnotations.kt") + public void testClassesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("constructorsWithAnnotations.kt") + public void testConstructorsWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/constructorsWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("enumsInAnnotationArguments.kt") + public void testEnumsInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("fieldsWithAnnotations.kt") + public void testFieldsWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/fieldsWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("functionsWithAnnotations.kt") + public void testFunctionsWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/functionsWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("propertiesWithAnnotations.kt") + public void testPropertiesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/propertiesWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("propertyAccessorsWithAnnotations.kt") + public void testPropertyAccessorsWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("typeAliasesWithAnnotations.kt") + public void testTypeAliasesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/typeAliasesWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("valueParametersWithAnnotations.kt") + public void testValueParametersWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("varargsInAnnotationArguments.kt") + public void testVarargsInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/varargsInAnnotationArguments.kt"); + doTest(fileName); + } + + @TestMetadata("variablesWithAnnotations.kt") + public void testVariablesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/variablesWithAnnotations.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)