diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt index 472c9bb96dc..ec8e763320f 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ModuleGenerator.kt @@ -22,10 +22,14 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl import org.jetbrains.kotlin.ir.declarations.impl.IrModuleFragmentImpl import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator import org.jetbrains.kotlin.psi.KtFile +import org.jetbrains.kotlin.psi2ir.transformations.AnnotationGenerator import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.lazy.descriptors.findPackageFragmentForFile class ModuleGenerator(override val context: GeneratorContext) : Generator { + + private val annotationGenerator = AnnotationGenerator(context) + fun generateModuleFragment(ktFiles: Collection): IrModuleFragment = generateModuleFragmentWithoutDependencies(ktFiles).also { irModule -> generateUnboundSymbolsAsDependencies(irModule) @@ -52,7 +56,9 @@ class ModuleGenerator(override val context: GeneratorContext) : Generator { val irFile = createEmptyIrFile(ktFile) for (ktAnnotationEntry in ktFile.annotationEntries) { - irFile.fileAnnotations.add(getOrFail(BindingContext.ANNOTATION, ktAnnotationEntry)) + val annotationDescriptor = getOrFail(BindingContext.ANNOTATION, ktAnnotationEntry) + irFile.fileAnnotations.add(annotationDescriptor) + irFile.annotations.add(annotationGenerator.generateAnnotationConstructorCall(annotationDescriptor)) } for (ktDeclaration in ktFile.declarations) { 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 index fb9bedcbfc1..aab1d0f9c14 100644 --- 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 @@ -6,16 +6,13 @@ 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.descriptors.annotations.AnnotationWithTarget 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.declarations.* import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid @@ -45,12 +42,31 @@ class AnnotationGenerator(private val context: GeneratorContext) : IrElementVisi generateAnnotationsForDeclaration(declaration) } - private fun generateAnnotationsForDeclaration(declaration: IrDeclaration) { - val allAnnotations = declaration.descriptor.annotations.getAllAnnotations() - val matchingAnnotations = allAnnotations.filter { - isAnnotationTargetMatchingDeclaration(it.target, declaration) + override fun visitValueParameter(declaration: IrValueParameter) { + super.visitValueParameter(declaration) + + val descriptor = declaration.descriptor + val containingDeclaration = descriptor.containingDeclaration + + if (containingDeclaration is PropertySetterDescriptor) { + containingDeclaration.correspondingProperty.annotations.getUseSiteTargetedAnnotations() + .filter { it.target == AnnotationUseSiteTarget.SETTER_PARAMETER } + .generateAnnotationConstructorCalls(declaration) } - matchingAnnotations.mapTo(declaration.annotations) { + + descriptor.type.annotations.getAllAnnotations() + .filter { it.target == AnnotationUseSiteTarget.RECEIVER } + .generateAnnotationConstructorCalls(declaration) + } + + private fun generateAnnotationsForDeclaration(declaration: IrDeclaration) { + declaration.descriptor.annotations.getAllAnnotations() + .filter { isAnnotationTargetMatchingDeclaration(it.target, declaration) } + .generateAnnotationConstructorCalls(declaration) + } + + private fun List.generateAnnotationConstructorCalls(declaration: IrDeclaration) { + mapTo(declaration.annotations) { generateAnnotationConstructorCall(it.annotation) } } @@ -80,8 +96,7 @@ class AnnotationGenerator(private val context: GeneratorContext) : IrElementVisi 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 argumentValue = annotationDescriptor.allValueArguments[valueParameter.name] ?: continue val irArgument = constantValueGenerator.generateConstantValueAsExpression( UNDEFINED_OFFSET, @@ -97,18 +112,17 @@ class AnnotationGenerator(private val context: GeneratorContext) : IrElementVisi private fun isAnnotationTargetMatchingDeclaration(target: AnnotationUseSiteTarget?, element: IrElement): Boolean = when (element) { - is IrProperty -> target == null || target == AnnotationUseSiteTarget.PROPERTY + is IrProperty -> + target == null || target == AnnotationUseSiteTarget.PROPERTY - is IrField -> target == AnnotationUseSiteTarget.FIELD + is IrField -> + target == AnnotationUseSiteTarget.FIELD || target == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD is IrSimpleFunction -> - target == null || element.descriptor.let { - when (it) { - is PropertyGetterDescriptor -> target == AnnotationUseSiteTarget.PROPERTY_GETTER - is PropertySetterDescriptor -> target == AnnotationUseSiteTarget.PROPERTY_SETTER - else -> false - } - } + target == null || target == AnnotationUseSiteTarget.PROPERTY_GETTER || target == AnnotationUseSiteTarget.PROPERTY_SETTER + + is IrValueParameter -> + target == null || target == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER else -> target == null } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt index a8f7371a8d9..0c1e0e23273 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt @@ -47,24 +47,26 @@ interface IrImplementingDelegateDescriptor : IrDelegateDescriptor { abstract class IrDelegateDescriptorBase( containingDeclaration: DeclarationDescriptor, name: Name, - delegateType: KotlinType -) : PropertyDescriptorImpl( - containingDeclaration, - /* original = */ null, - Annotations.EMPTY, - Modality.FINAL, - Visibilities.PRIVATE, - /* isVar = */ false, - name, - CallableMemberDescriptor.Kind.SYNTHESIZED, - SourceElement.NO_SOURCE, - /* lateInit = */ false, - /* isConst = */ false, - /* isExpect = */ false, - /* isActual = */ false, - /* isExternal = */ false, - /* isDelegated = */ true -) { + delegateType: KotlinType, + annotations: Annotations = Annotations.EMPTY +) : + PropertyDescriptorImpl( + containingDeclaration, + /* original = */ null, + annotations, + Modality.FINAL, + Visibilities.PRIVATE, + /* isVar = */ false, + name, + CallableMemberDescriptor.Kind.SYNTHESIZED, + SourceElement.NO_SOURCE, + /* lateInit = */ false, + /* isConst = */ false, + /* isExpect = */ false, + /* isActual = */ false, + /* isExternal = */ false, + /* isDelegated = */ true + ) { init { val typeParameters: List = emptyList() val extensionReceiverParameter: ReceiverParameterDescriptor? = null @@ -75,7 +77,7 @@ abstract class IrDelegateDescriptorBase( setType(delegateType, typeParameters, dispatchReceiverParameter, extensionReceiverParameter) } - override final fun setOutType(outType: KotlinType?) { + final override fun setOutType(outType: KotlinType?) { super.setOutType(outType) } @@ -97,21 +99,26 @@ class IrPropertyDelegateDescriptorImpl( override val correspondingProperty: PropertyDescriptor, delegateType: KotlinType, override val kPropertyType: KotlinType -) : IrDelegateDescriptorBase( - correspondingProperty.containingDeclaration, - getDelegateName(correspondingProperty.name), - delegateType -), IrPropertyDelegateDescriptor +) : + IrDelegateDescriptorBase( + correspondingProperty.containingDeclaration, + getDelegateName(correspondingProperty.name), + delegateType, + correspondingProperty.annotations + ), + IrPropertyDelegateDescriptor class IrImplementingDelegateDescriptorImpl( containingDeclaration: ClassDescriptor, delegateType: KotlinType, override val correspondingSuperType: KotlinType -) : IrDelegateDescriptorBase( - containingDeclaration, - getDelegateName(containingDeclaration, correspondingSuperType), - delegateType -), IrImplementingDelegateDescriptor +) : + IrDelegateDescriptorBase( + containingDeclaration, + getDelegateName(containingDeclaration, correspondingSuperType), + delegateType + ), + IrImplementingDelegateDescriptor internal fun getDelegateName(name: Name): Name = Name.identifier(name.asString() + "\$delegate") 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 01795fc4fce..6b1ce661217 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 @@ -80,7 +80,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapPackageFragmentDescriptor(declaration.packageFragmentDescriptor), declaration.fileAnnotations.toMutableList(), declaration.declarations.map { it.transform() } - ) + ).apply { + transformAnnotations(declaration) + } override fun visitDeclaration(declaration: IrDeclaration): IrStatement = throw IllegalArgumentException("Unsupported declaration type: $declaration") @@ -202,6 +204,7 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapDeclarationOrigin(originalTypeParameter.origin), newTypeParameterDescriptor ).apply { + transformAnnotations(originalTypeParameter) for (i in upperBounds.indices) { val upperBoundClassifier = upperBounds[i].constructor.declarationDescriptor ?: continue val oldSuperClassifierSymbol = originalTypeParameter.superClassifiers[i] @@ -268,7 +271,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { declaration.delegate.transform(), declaration.getter.transform(), declaration.setter?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry = IrEnumEntryImpl( @@ -277,7 +282,9 @@ open class DeepCopyIrTree : IrElementTransformerVoid() { mapEnumEntryDeclaration(declaration.descriptor), declaration.correspondingClass?.transform(), declaration.initializerExpression?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer): IrAnonymousInitializer = IrAnonymousInitializerImpl( 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 f615b648e55..446f48f61fc 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 @@ -73,6 +73,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) declaration.fileEntry, symbolRemapper.getDeclaredFile(declaration.symbol) ).apply { + transformAnnotations(declaration) fileAnnotations.addAll(declaration.fileAnnotations) declaration.transformDeclarationsTo(this) } @@ -135,7 +136,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) body = declaration.body?.transform() } - private fun IrDeclaration.transformAnnotations(declaration: IrDeclaration) { + private fun IrAnnotationContainer.transformAnnotations(declaration: IrAnnotationContainer) { declaration.annotations.transformTo(annotations) } @@ -170,7 +171,9 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) declaration.delegate.transform(), declaration.getter.transform(), declaration.setter?.transform() - ) + ).apply { + transformAnnotations(declaration) + } override fun visitEnumEntry(declaration: IrEnumEntry): IrEnumEntry = IrEnumEntryImpl( @@ -178,6 +181,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredEnumEntry(declaration.symbol) ).apply { + transformAnnotations(declaration) correspondingClass = declaration.correspondingClass?.transform() initializerExpression = declaration.initializerExpression?.transform() } @@ -207,6 +211,7 @@ open class DeepCopyIrTreeWithSymbols(private val symbolRemapper: SymbolRemapper) mapDeclarationOrigin(declaration.origin), symbolRemapper.getDeclaredTypeParameter(declaration.symbol) ).apply { + transformAnnotations(declaration) declaration.superClassifiers.mapTo(superClassifiers) { symbolRemapper.getReferencedClassifier(it) } 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 5e4bbc57f1c..aeea5067874 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 @@ -78,6 +78,7 @@ class DumpIrTreeVisitor(out: Appendable) : IrElementVisitor { } } } + dumpAnnotations(declaration) declaration.declarations.dumpElements() } } diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt new file mode 100644 index 00000000000..99bfca373cb --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt @@ -0,0 +1,7 @@ +annotation class A(val x: String = "", val y: Int = 42) + +@A("abc", 123) fun test1() {} +@A("def") fun test2() {} +@A(x = "ghi") fun test3() {} +@A(y = 456) fun test4() {} +@A fun test5() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.txt new file mode 100644 index 00000000000..94d8b374ef9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.txt @@ -0,0 +1,70 @@ +FILE fqName: fileName:/annotationsWithDefaultParameterValues.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String, y:kotlin.Int) returnType:A flags: + VALUE_PARAMETER name:x index:0 type:kotlin.String flags: + EXPRESSION_BODY + CONST String type=kotlin.String value= + VALUE_PARAMETER name:y index:1 type:kotlin.Int flags: + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + 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:A) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@A: A' type=A origin=null + PROPERTY name:y type:kotlin.Int visibility:public modality:FINAL flags:val + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter y: Int = ...' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:A) returnType:Int flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'y: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@A: A' type=A 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 A(String = ..., Int = ...)' type=A origin=null + x: CONST String type=kotlin.String value=abc + y: CONST Int type=kotlin.Int value=123 + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(String = ..., Int = ...)' type=A origin=null + x: CONST String type=kotlin.String value=def + BLOCK_BODY + FUN name:test3 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(String = ..., Int = ...)' type=A origin=null + x: CONST String type=kotlin.String value=ghi + BLOCK_BODY + FUN name:test4 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(String = ..., Int = ...)' type=A origin=null + y: CONST Int type=kotlin.Int value=456 + BLOCK_BODY + FUN name:test5 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(String = ..., Int = ...)' type=A origin=null + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt new file mode 100644 index 00000000000..efce4a1ef4b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt @@ -0,0 +1,5 @@ +annotation class A(vararg val xs: String) + +@A("abc", "def") fun test1() {} +@A("abc") fun test2() {} +@A fun test3() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.txt b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.txt new file mode 100644 index 00000000000..781d685b6ce --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/annotationsWithVarargParameters.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:A 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:A) returnType:Array flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'xs: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@A: A' type=A 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 A(vararg String)' type=A origin=null + xs: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=abc + CONST String type=kotlin.String value=def + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(vararg String)' type=A origin=null + xs: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=abc + BLOCK_BODY + FUN name:test3 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(vararg String)' type=A origin=null + xs: VARARG type=Array varargElementType=String + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt new file mode 100644 index 00000000000..0e952d252a1 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.kt @@ -0,0 +1,6 @@ +const val ONE = 1 + +annotation class A(val x: Int) + +@A(ONE) fun test1() {} +@A(1+1) fun test2() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.txt new file mode 100644 index 00000000000..20650f04a4e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/constExpressionsInAnnotationArguments.kt + PROPERTY name:ONE type:kotlin.Int visibility:public modality:FINAL flags:constmval + FIELD PROPERTY_BACKING_FIELD name:ONE type:kotlin.Int visibility:public + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'ONE: Int' type=kotlin.Int origin=null + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:A 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:A) returnType:Int flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@A: A' type=A 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 A(Int)' type=A origin=null + x: CONST Int type=kotlin.Int value=1 + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A(Int)' type=A origin=null + x: CONST Int type=kotlin.Int value=2 + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt new file mode 100644 index 00000000000..58bafe00761 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt @@ -0,0 +1,6 @@ +// WITH_RUNTIME + +annotation class Ann + +@delegate:Ann +val test1 by lazy { 42 } \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt new file mode 100644 index 00000000000..3bb511c2cbb --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.txt @@ -0,0 +1,40 @@ +FILE fqName: fileName:/delegateFieldWithAnnotations.kt + CLASS ANNOTATION_CLASS name:Ann modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Ann flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:Ann 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: + PROPERTY name:test1 type:kotlin.Int visibility:public modality:FINAL flags:delegatedmval + FIELD DELEGATE name:test1$delegate type:kotlin.Lazy visibility:private + annotations: + CALL 'constructor Ann()' type=Ann origin=null + EXPRESSION_BODY + CALL 'lazy(() -> Int): Lazy' type=kotlin.Lazy origin=null + : Int + initializer: BLOCK type=() -> kotlin.Int origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CONST Int type=kotlin.Int value=42 + FUNCTION_REFERENCE '(): Int' type=() -> kotlin.Int origin=LAMBDA + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CALL 'getValue(Any?, KProperty<*>) on Lazy: Int' type=kotlin.Int origin=null + : Int + $receiver: GET_FIELD '`test1$delegate`: Lazy' type=kotlin.Lazy origin=null + thisRef: CONST Null type=kotlin.Nothing? value=null + property: PROPERTY_REFERENCE 'test1: Int' field=null getter='(): Int' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt new file mode 100644 index 00000000000..6c6b2bd429f --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt @@ -0,0 +1,17 @@ +annotation class A(val x: String) + +class Cell(var value: Int) { + operator fun getValue(thisRef: Any?, kProp: Any?) = value + + operator fun setValue(thisRef: Any?, kProp: Any?, newValue: Int) { + value = newValue + } +} + +@get:A("test1.get") +val test1 by Cell(1) + +@get:A("test2.get") +@set:A("test2.set") +@setparam:A("test2.set.param") +var test2 by Cell(2) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.txt new file mode 100644 index 00000000000..18e819a9e37 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.txt @@ -0,0 +1,131 @@ +FILE fqName: fileName:/delegatedPropertyAccessorsWithAnnotations.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:A 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:A) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@A: A' type=A 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:Cell modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Cell flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> (value:kotlin.Int) returnType:Cell flags: + VALUE_PARAMETER name:value index:0 type:kotlin.Int flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='Cell' + PROPERTY name:value type:kotlin.Int visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:Cell) returnType:Int flags: + $this: VALUE_PARAMETER name: type:Cell flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'value: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@Cell: Cell' type=Cell origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:Cell, :kotlin.Int) returnType:Unit flags: + $this: VALUE_PARAMETER name: type:Cell flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + BLOCK_BODY + SET_FIELD 'value: Int' type=kotlin.Unit origin=null + receiver: GET_VAR 'this@Cell: Cell' type=Cell origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null + FUN name:getValue visibility:public modality:FINAL <> ($this:Cell, thisRef:kotlin.Any?, kProp:kotlin.Any?) returnType:Int flags: + $this: VALUE_PARAMETER name: type:Cell flags: + VALUE_PARAMETER name:thisRef index:0 type:kotlin.Any? flags: + VALUE_PARAMETER name:kProp index:1 type:kotlin.Any? flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='getValue(Any?, Any?): Int' + CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'this@Cell: Cell' type=Cell origin=null + FUN name:setValue visibility:public modality:FINAL <> ($this:Cell, thisRef:kotlin.Any?, kProp:kotlin.Any?, newValue:kotlin.Int) returnType:Unit flags: + $this: VALUE_PARAMETER name: type:Cell flags: + VALUE_PARAMETER name:thisRef index:0 type:kotlin.Any? flags: + VALUE_PARAMETER name:kProp index:1 type:kotlin.Any? flags: + VALUE_PARAMETER name:newValue index:2 type:kotlin.Int flags: + BLOCK_BODY + CALL '(Int): Unit' type=kotlin.Unit origin=EQ + $this: GET_VAR 'this@Cell: Cell' type=Cell origin=null + : GET_VAR 'value-parameter newValue: Int' type=kotlin.Int 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: + PROPERTY name:test1 type:kotlin.Int visibility:public modality:FINAL flags:delegatedmval + FIELD DELEGATE name:test1$delegate type:Cell visibility:private + EXPRESSION_BODY + CALL 'constructor Cell(Int)' type=Cell origin=null + value: CONST Int type=kotlin.Int value=1 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:Int flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=test1.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CALL 'getValue(Any?, Any?): Int' type=kotlin.Int origin=null + $this: GET_FIELD '`test1$delegate`: Cell' type=Cell origin=null + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'test1: Int' field=null getter='(): Int' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + PROPERTY name:test2 type:kotlin.Int visibility:public modality:FINAL flags:delegatedmvar + FIELD DELEGATE name:test2$delegate type:Cell visibility:private + EXPRESSION_BODY + CALL 'constructor Cell(Int)' type=Cell origin=null + value: CONST Int type=kotlin.Int value=2 + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:Int flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=test2.get + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CALL 'getValue(Any?, Any?): Int' type=kotlin.Int origin=null + $this: GET_FIELD '`test2$delegate`: Cell' type=Cell origin=null + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'test2: Int' field=null getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:Unit flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=test2.set + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=test2.set.param + BLOCK_BODY + RETURN type=kotlin.Nothing from='(Int): Unit' + CALL 'setValue(Any?, Any?, Int): Unit' type=kotlin.Unit origin=null + $this: GET_FIELD '`test2$delegate`: Cell' type=Cell origin=null + thisRef: CONST Null type=kotlin.Nothing? value=null + kProp: PROPERTY_REFERENCE 'test2: Int' field=null getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + newValue: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt new file mode 100644 index 00000000000..67414e9da2e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt @@ -0,0 +1,8 @@ +annotation class TestAnn(val x: String) + +enum class TestEnum { + @TestAnn("ENTRY1") ENTRY1, + @TestAnn("ENTRY2") ENTRY2 { + val x = 42 + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt new file mode 100644 index 00000000000..b4ddce640d0 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt @@ -0,0 +1,155 @@ +FILE fqName: fileName:/enumEntriesWithAnnotations.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 ENUM_CLASS name:TestEnum modality:FINAL visibility:public flags: + $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' + ENUM_ENTRY name:ENTRY1 + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=ENTRY1 + init: ENUM_CONSTRUCTOR_CALL 'constructor TestEnum()' + ENUM_ENTRY name:ENTRY2 + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=ENTRY2 + init: ENUM_CONSTRUCTOR_CALL 'constructor ENTRY2()' + class: CLASS ENUM_ENTRY name:ENTRY2 modality:FINAL visibility:public flags: + annotations: + CALL 'constructor TestAnn(String)' type=TestAnn origin=null + x: CONST String type=kotlin.String value=ENTRY2 + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:TestEnum.ENTRY2 flags: + superClasses: + CLASS ENUM_CLASS name:TestEnum modality:FINAL visibility:public flags: + CONSTRUCTOR visibility:private <> () returnType:TestEnum.ENTRY2 flags: + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'constructor TestEnum()' + INSTANCE_INITIALIZER_CALL classDescriptor='ENTRY2' + 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 + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:TestEnum.ENTRY2) returnType:Int flags: + $this: VALUE_PARAMETER name: type:TestEnum.ENTRY2 flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@ENTRY2: ENTRY2' type=TestEnum.ENTRY2 origin=null + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:Any flags: + overridden: + FUN FAKE_OVERRIDE 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 FAKE_OVERRIDE 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 FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum) returnType:(java.lang.Class<(TestEnum..TestEnum?)>..java.lang.Class<(TestEnum..TestEnum?)>?) 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 FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:TestEnum) 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 FAKE_OVERRIDE 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 FAKE_OVERRIDE 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 FAKE_OVERRIDE 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 FAKE_OVERRIDE 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 FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum) returnType:String flags: + $this: VALUE_PARAMETER name: type:kotlin.Enum flags: + 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 diff --git a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt new file mode 100644 index 00000000000..10b54831ab0 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.kt @@ -0,0 +1,5 @@ +@file:A("File annotation") +package test + +@Target(AnnotationTarget.FILE) +annotation class A(val x: String) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.txt new file mode 100644 index 00000000000..29f661b2fee --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/fileAnnotations.txt @@ -0,0 +1,39 @@ +FILE fqName:test fileName:/fileAnnotations.kt + fileAnnotations: + @test.A(x = "File annotation") + annotations: + CALL 'constructor A(String)' type=test.A origin=null + x: CONST String type=kotlin.String value=File annotation + CLASS ANNOTATION_CLASS name:A 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 'FILE' type=kotlin.annotation.AnnotationTarget + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:test.A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:test.A 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:test.A) returnType:String flags: + $this: VALUE_PARAMETER name: type:test.A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@A: A' type=test.A 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: diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt new file mode 100644 index 00000000000..601b836f4c5 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt @@ -0,0 +1,8 @@ +// WITH_RUNTIME + +annotation class A(val x: String) + +fun foo(m: Map) { + @A("foo/test") + val test by lazy { 42 } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt new file mode 100644 index 00000000000..5fd8b6d2e9e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.txt @@ -0,0 +1,54 @@ +FILE fqName: fileName:/localDelegatedPropertiesWithAnnotations.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:A 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:A) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@A: A' type=A 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 <> (m:kotlin.collections.Map) returnType:Unit flags: + VALUE_PARAMETER name:m index:0 type:kotlin.collections.Map flags: + BLOCK_BODY + LOCAL_DELEGATED_PROPERTY name:test type:kotlin.Int flags:val + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=foo/test + VAR DELEGATE name:test$delegate type:kotlin.Lazy flags:val + CALL 'lazy(() -> Int): Lazy' type=kotlin.Lazy origin=null + : Int + initializer: BLOCK type=() -> kotlin.Int origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CONST Int type=kotlin.Int value=42 + FUNCTION_REFERENCE '(): Int' type=() -> kotlin.Int origin=LAMBDA + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:local modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + CALL 'getValue(Any?, KProperty<*>) on Lazy: Int' type=kotlin.Int origin=null + : Int + $receiver: GET_VAR '`test$delegate`: Lazy' type=kotlin.Lazy origin=null + thisRef: CONST Null type=kotlin.Nothing? value=null + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'test: Int' delegate='`test$delegate`: Lazy' getter='(): Int' setter=null type=kotlin.reflect.KProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE diff --git a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt new file mode 100644 index 00000000000..09a1dec3c10 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt @@ -0,0 +1,5 @@ +annotation class A1 +annotation class A2 +annotation class A3 + +@[A1, A2, A3] fun test() {} diff --git a/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.txt b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.txt new file mode 100644 index 00000000000..ae100f4fcb9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.txt @@ -0,0 +1,61 @@ +FILE fqName: fileName:/multipleAnnotationsInSquareBrackets.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 <> () returnType:A1 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: + 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 <> () returnType:A2 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: + CLASS ANNOTATION_CLASS name:A3 modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A3 flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:A3 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: + FUN name:test visibility:public modality:FINAL <> () returnType:Unit flags: + annotations: + CALL 'constructor A1()' type=A1 origin=null + CALL 'constructor A2()' type=A2 origin=null + CALL 'constructor A3()' type=A3 origin=null + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt new file mode 100644 index 00000000000..1388d1ae923 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.kt @@ -0,0 +1,3 @@ +annotation class Ann + +class Test(@param:Ann val x: Int) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.txt new file mode 100644 index 00000000000..f0c559a95a3 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.txt @@ -0,0 +1,53 @@ +FILE fqName: fileName:/primaryConstructorParameterWithAnnotations.kt + CLASS ANNOTATION_CLASS name:Ann modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Ann flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:Ann 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: + CLASS CLASS name:Test modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Test flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:Test flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor Ann()' type=Ann origin=null + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='Test' + 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:Test) returnType:Int flags: + $this: VALUE_PARAMETER name: type:Test flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@Test: Test' type=Test 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/propertyAccessorsFromClassHeaderWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt new file mode 100644 index 00000000000..5f1a8a586d9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.kt @@ -0,0 +1,6 @@ +annotation class A(val x: String) + +class C( + @get:A("C.x.get") val x: Int, + @get:A("C.y.get") @set:A("C.y.set") var y: Int +) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.txt new file mode 100644 index 00000000000..57646edecf7 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.txt @@ -0,0 +1,89 @@ +FILE fqName: fileName:/propertyAccessorsFromClassHeaderWithAnnotations.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.String) returnType:A 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:A) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): String' + GET_FIELD 'x: String' type=kotlin.String origin=null + receiver: GET_VAR 'this@A: A' type=A 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:C modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:C flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> (x:kotlin.Int, y:kotlin.Int) returnType:C flags: + VALUE_PARAMETER name:x index:0 type:kotlin.Int flags: + VALUE_PARAMETER name:y index:1 type:kotlin.Int flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='C' + 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:C) returnType:Int flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=C.x.get + $this: VALUE_PARAMETER name: type:C flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'x: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + PROPERTY name:y type:kotlin.Int visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter y: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C) returnType:Int flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=C.y.get + $this: VALUE_PARAMETER name: type:C flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'y: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C, :kotlin.Int) returnType:Unit flags: + annotations: + CALL 'constructor A(String)' type=A origin=null + x: CONST String type=kotlin.String value=C.y.set + $this: VALUE_PARAMETER name: type:C flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + BLOCK_BODY + SET_FIELD 'y: Int' type=kotlin.Unit origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int 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/propertySetterParameterWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt new file mode 100644 index 00000000000..9a227055b3d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt @@ -0,0 +1,6 @@ +annotation class AnnParam + +@setparam:AnnParam +var p: Int = 0 + +class C(@setparam:AnnParam var p: Int) \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.txt new file mode 100644 index 00000000000..88bad1fcda1 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.txt @@ -0,0 +1,75 @@ +FILE fqName: fileName:/propertySetterParameterWithAnnotations.kt + CLASS ANNOTATION_CLASS name:AnnParam modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:AnnParam flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:AnnParam 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: + PROPERTY name:p type:kotlin.Int visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:public + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:Int flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'p: Int' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:Unit flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor AnnParam()' type=AnnParam origin=null + BLOCK_BODY + SET_FIELD 'p: Int' type=kotlin.Unit origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int origin=null + CLASS CLASS name:C modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:C flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> (p:kotlin.Int) returnType:C flags: + VALUE_PARAMETER name:p index:0 type:kotlin.Int flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='C' + PROPERTY name:p type:kotlin.Int visibility:public modality:FINAL flags:var + FIELD PROPERTY_BACKING_FIELD name:p type:kotlin.Int visibility:public + EXPRESSION_BODY + GET_VAR 'value-parameter p: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C) returnType:Int flags: + $this: VALUE_PARAMETER name: type:C flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Int' + GET_FIELD 'p: Int' type=kotlin.Int origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:C, :kotlin.Int) returnType:Unit flags: + $this: VALUE_PARAMETER name: type:C flags: + VALUE_PARAMETER name: index:0 type:kotlin.Int flags: + annotations: + CALL 'constructor AnnParam()' type=AnnParam origin=null + BLOCK_BODY + SET_FIELD 'p: Int' type=kotlin.Unit origin=null + receiver: GET_VAR 'this@C: C' type=C origin=null + value: GET_VAR 'value-parameter : Int' type=kotlin.Int 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/receiverParameterWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.kt new file mode 100644 index 00000000000..86297f6032d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.kt @@ -0,0 +1,14 @@ +annotation class Ann + +class A { + fun @receiver:Ann String.f(): String = "" + + val @receiver:Ann String?.p: String + get() = "" + +} + +fun @receiver:Ann String?.topLevelF(): String = "" + +val @receiver:Ann String.topLevelP: String + get() = "" diff --git a/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.txt new file mode 100644 index 00000000000..066ad21abd3 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.txt @@ -0,0 +1,72 @@ +FILE fqName: fileName:/receiverParameterWithAnnotations.kt + CLASS ANNOTATION_CLASS name:Ann modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Ann flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:Ann 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: + CLASS CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:A flags: + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' + INSTANCE_INITIALIZER_CALL classDescriptor='A' + FUN name:f visibility:public modality:FINAL <> ($this:A, $receiver:@receiver:Ann kotlin.String) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + $receiver: VALUE_PARAMETER name: type:@receiver:Ann kotlin.String flags: + annotations: + CALL 'constructor Ann()' type=Ann origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='f() on String: String' + CONST String type=kotlin.String value= + PROPERTY name:p type:kotlin.String visibility:public modality:FINAL flags:val + FUN name: visibility:public modality:FINAL <> ($this:A, $receiver:@receiver:Ann kotlin.String?) returnType:String flags: + $this: VALUE_PARAMETER name: type:A flags: + $receiver: VALUE_PARAMETER name: type:@receiver:Ann kotlin.String? flags: + annotations: + CALL 'constructor Ann()' type=Ann origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='() on String?: String' + CONST String type=kotlin.String value= + 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 name:topLevelF visibility:public modality:FINAL <> ($receiver:@receiver:Ann kotlin.String?) returnType:String flags: + $receiver: VALUE_PARAMETER name: type:@receiver:Ann kotlin.String? flags: + annotations: + CALL 'constructor Ann()' type=Ann origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='topLevelF() on String?: String' + CONST String type=kotlin.String value= + PROPERTY name:topLevelP type:kotlin.String visibility:public modality:FINAL flags:val + FUN name: visibility:public modality:FINAL <> ($receiver:@receiver:Ann kotlin.String) returnType:String flags: + $receiver: VALUE_PARAMETER name: type:@receiver:Ann kotlin.String flags: + annotations: + CALL 'constructor Ann()' type=Ann origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='() on String: String' + CONST String type=kotlin.String value= diff --git a/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.kt b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.kt new file mode 100644 index 00000000000..bedcc898c7d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.kt @@ -0,0 +1,5 @@ +annotation class A(vararg val xs: String) + + +@A(*arrayOf("a"), *arrayOf("b")) +fun test() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.txt b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.txt new file mode 100644 index 00000000000..c7aab3f8220 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.txt @@ -0,0 +1,39 @@ +FILE fqName: fileName:/spreadOperatorInAnnotationArguments.kt + CLASS ANNOTATION_CLASS name:A modality:FINAL visibility:public flags: + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:A flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> (xs:kotlin.Array) returnType:A 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:A) returnType:Array flags: + $this: VALUE_PARAMETER name: type:A flags: + BLOCK_BODY + RETURN type=kotlin.Nothing from='(): Array' + GET_FIELD 'xs: Array' type=kotlin.Array origin=null + receiver: GET_VAR 'this@A: A' type=A 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 A(vararg String)' type=A origin=null + xs: VARARG type=Array varargElementType=String + VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=a + VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=b + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt new file mode 100644 index 00000000000..ca6b718bb9c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt @@ -0,0 +1,4 @@ +@Target(AnnotationTarget.TYPE_PARAMETER) +annotation class Anno + +fun <@Anno T> foo() {} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.txt new file mode 100644 index 00000000000..d0ac4b3a328 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.txt @@ -0,0 +1,30 @@ +FILE fqName: fileName:/typeParametersWithAnnotations.kt + CLASS ANNOTATION_CLASS name:Anno 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 'TYPE_PARAMETER' type=kotlin.annotation.AnnotationTarget + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:Anno flags: + superClasses: + CLASS IR_EXTERNAL_DECLARATION_STUB INTERFACE name:Annotation modality:ABSTRACT visibility:public flags: + CONSTRUCTOR visibility:public <> () returnType:Anno 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: + FUN name:foo visibility:public modality:FINAL () returnType:Unit flags: + TYPE_PARAMETER name:T index:0 variance: upperBounds:[kotlin.Any?] + annotations: + CALL 'constructor Anno()' type=Anno origin=null + superClassifiers: + CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Any modality:OPEN visibility:public flags: + BLOCK_BODY diff --git a/compiler/testData/ir/irText/declarations/fileWithAnnotations.txt b/compiler/testData/ir/irText/declarations/fileWithAnnotations.txt index bed7e37fd24..f49e10aaa16 100644 --- a/compiler/testData/ir/irText/declarations/fileWithAnnotations.txt +++ b/compiler/testData/ir/irText/declarations/fileWithAnnotations.txt @@ -1,6 +1,9 @@ FILE fqName: fileName:/fileWithAnnotations.kt fileAnnotations: @kotlin.jvm.JvmName(name = "FileWithAnnotations") + annotations: + CALL 'constructor JvmName(String)' type=kotlin.jvm.JvmName origin=null + name: CONST String type=kotlin.String value=FileWithAnnotations FUN name:foo visibility:public modality:FINAL <> () returnType:Unit flags: BLOCK_BODY PROPERTY name:bar type:kotlin.Int visibility:public modality:FINAL flags:val diff --git a/compiler/testData/ir/irText/declarations/typeAlias.txt b/compiler/testData/ir/irText/declarations/typeAlias.txt index 151e0f95522..6cd1aac5136 100644 --- a/compiler/testData/ir/irText/declarations/typeAlias.txt +++ b/compiler/testData/ir/irText/declarations/typeAlias.txt @@ -3,6 +3,10 @@ FILE fqName: fileName:/typeAlias.kt FUN name:foo visibility:public modality:FINAL <> () returnType:Unit flags: BLOCK_BODY TYPEALIAS typealias TestLocal = String type=kotlin.String + annotations: + CALL 'constructor Suppress(vararg String)' type=kotlin.Suppress origin=null + names: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=TOPLEVEL_TYPEALIASES_ONLY CLASS CLASS name:C modality:FINAL visibility:public flags: $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:C flags: superClasses: @@ -12,6 +16,10 @@ FILE fqName: fileName:/typeAlias.kt DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' INSTANCE_INITIALIZER_CALL classDescriptor='C' TYPEALIAS typealias TestNested = String type=kotlin.String + annotations: + CALL 'constructor Suppress(vararg String)' type=kotlin.Suppress origin=null + names: VARARG type=Array varargElementType=String + CONST String type=kotlin.String value=TOPLEVEL_TYPEALIASES_ONLY 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: diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 73c61a8a5e3..d5b6c0f3708 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -344,6 +344,18 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("annotationsWithDefaultParameterValues.kt") + public void testAnnotationsWithDefaultParameterValues() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/annotationsWithDefaultParameterValues.kt"); + doTest(fileName); + } + + @TestMetadata("annotationsWithVarargParameters.kt") + public void testAnnotationsWithVarargParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/annotationsWithVarargParameters.kt"); + doTest(fileName); + } + @TestMetadata("arrayInAnnotationArguments.kt") public void testArrayInAnnotationArguments() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/arrayInAnnotationArguments.kt"); @@ -356,12 +368,36 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("constExpressionsInAnnotationArguments.kt") + public void testConstExpressionsInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/constExpressionsInAnnotationArguments.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("delegateFieldWithAnnotations.kt") + public void testDelegateFieldWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/delegateFieldWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("delegatedPropertyAccessorsWithAnnotations.kt") + public void testDelegatedPropertyAccessorsWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/delegatedPropertyAccessorsWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("enumEntriesWithAnnotations.kt") + public void testEnumEntriesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.kt"); + doTest(fileName); + } + @TestMetadata("enumsInAnnotationArguments.kt") public void testEnumsInAnnotationArguments() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.kt"); @@ -374,30 +410,84 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("fileAnnotations.kt") + public void testFileAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/fileAnnotations.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("localDelegatedPropertiesWithAnnotations.kt") + public void testLocalDelegatedPropertiesWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/localDelegatedPropertiesWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("multipleAnnotationsInSquareBrackets.kt") + public void testMultipleAnnotationsInSquareBrackets() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/multipleAnnotationsInSquareBrackets.kt"); + doTest(fileName); + } + + @TestMetadata("primaryConstructorParameterWithAnnotations.kt") + public void testPrimaryConstructorParameterWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/primaryConstructorParameterWithAnnotations.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("propertyAccessorsFromClassHeaderWithAnnotations.kt") + public void testPropertyAccessorsFromClassHeaderWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/propertyAccessorsFromClassHeaderWithAnnotations.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("propertySetterParameterWithAnnotations.kt") + public void testPropertySetterParameterWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/propertySetterParameterWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("receiverParameterWithAnnotations.kt") + public void testReceiverParameterWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/receiverParameterWithAnnotations.kt"); + doTest(fileName); + } + + @TestMetadata("spreadOperatorInAnnotationArguments.kt") + public void testSpreadOperatorInAnnotationArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/spreadOperatorInAnnotationArguments.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("typeParametersWithAnnotations.kt") + public void testTypeParametersWithAnnotations() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/typeParametersWithAnnotations.kt"); + doTest(fileName); + } + @TestMetadata("valueParametersWithAnnotations.kt") public void testValueParametersWithAnnotations() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/declarations/annotations/valueParametersWithAnnotations.kt");