From 8c7fad9a5e44ce1fbe2dacf1c1a2c20eac33a095 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Wed, 6 Apr 2022 20:54:26 +0300 Subject: [PATCH] [FIR] Support of type arguments in annotations ^KT-48444 Fixed --- ...CompilerTestFE10TestdataTestGenerated.java | 6 + ...irOldFrontendDiagnosticsTestGenerated.java | 6 + ...DiagnosticsWithLightTreeTestGenerated.java | 6 + .../converter/DeclarationsConverter.kt | 4 +- .../kotlin/fir/builder/RawFirBuilder.kt | 15 +- .../jetbrains/kotlin/fir/FirCallResolver.kt | 2 +- .../kotlin/fir/expressions/FirAnnotation.kt | 6 + .../fir/expressions/FirAnnotationCall.kt | 6 + .../builder/FirAnnotationBuilder.kt | 3 + .../builder/FirAnnotationCallBuilder.kt | 3 + .../expressions/impl/FirAnnotationCallImpl.kt | 14 + .../fir/expressions/impl/FirAnnotationImpl.kt | 14 + .../fir/tree/generator/NodeConfigurator.kt | 1 + .../box/annotations/genericAnnotations.kt | 2 - .../annotations/typeArgumentsInAnnotation.kt | 8 + .../annotations/typeArgumentsInAnnotation.txt | 11 + .../genericAnnotationClasses.fir.ir.txt | 244 ++++++++++++++++++ .../genericAnnotationClasses.fir.kt.txt | 102 ++++++++ .../annotations/genericAnnotationClasses.kt | 2 - .../test/runners/DiagnosticTestGenerated.java | 6 + .../testData/box/customParcelerScoping.kt | 2 - .../testData/box/customSerializerBoxing.kt | 2 - .../testData/box/customSerializerWriteWith.kt | 2 - .../testData/box/kt46567.kt | 2 - .../diagnostics/customParcelers.fir.kt | 26 +- .../diagnostics/deprecatedAnnotations.fir.kt | 6 +- 26 files changed, 465 insertions(+), 36 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt create mode 100644 compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.txt create mode 100644 compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.kt.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index ba4f6fe12ff..7c0fdd793ad 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -1446,6 +1446,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); } + @Test + @TestMetadata("typeArgumentsInAnnotation.kt") + public void testTypeArgumentsInAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt"); + } + @Test @TestMetadata("typeParameterAsAnnotation.kt") public void testTypeParameterAsAnnotation() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index c57972d51e8..77c35e2c266 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -1446,6 +1446,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); } + @Test + @TestMetadata("typeArgumentsInAnnotation.kt") + public void testTypeArgumentsInAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt"); + } + @Test @TestMetadata("typeParameterAsAnnotation.kt") public void testTypeParameterAsAnnotation() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index aa69332a734..51a73a5d311 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -1446,6 +1446,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); } + @Test + @TestMetadata("typeArgumentsInAnnotation.kt") + public void testTypeArgumentsInAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt"); + } + @Test @TestMetadata("typeParameterAsAnnotation.kt") public void testTypeParameterAsAnnotation() throws Exception { diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 2f9ab91efae..05ee8c35793 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -377,7 +377,8 @@ class DeclarationsConverter( CONSTRUCTOR_CALLEE -> constructorCalleePair = convertConstructorInvocation(unescapedAnnotation) } } - val name = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last()?.name ?: Name.special("") + val qualifier = (constructorCalleePair.first as? FirUserTypeRef)?.qualifier?.last() + val name = qualifier?.name ?: Name.special("") return buildAnnotationCall { source = unescapedAnnotation.toFirSourceElement() useSiteTarget = annotationUseSiteTarget ?: defaultAnnotationUseSiteTarget @@ -392,6 +393,7 @@ class DeclarationsConverter( this.name = name } extractArgumentsFrom(constructorCalleePair.second) + typeArguments += qualifier?.typeArgumentList?.typeArguments ?: listOf() } } diff --git a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index faff7d44eeb..943d468f2e5 100644 --- a/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/raw-fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -1738,9 +1738,7 @@ open class RawFirBuilder( referenceExpression!!.toFirSourceElement(), referenceExpression!!.getReferencedNameAsName(), FirTypeArgumentListImpl(ktQualifier?.typeArgumentList?.toKtPsiSourceElement() ?: source).apply { - for (typeArgument in ktQualifier!!.typeArguments) { - typeArguments += typeArgument.convert() - } + typeArguments.appendTypeArguments(ktQualifier!!.typeArguments) } ) qualifier.add(firQualifier) @@ -1809,6 +1807,7 @@ open class RawFirBuilder( source = (annotationEntry.typeReference?.typeElement as? KtUserType)?.referenceExpression?.toFirSourceElement() this.name = name } + typeArguments.appendTypeArguments(annotationEntry.typeArguments) } } @@ -2358,9 +2357,7 @@ open class RawFirBuilder( return result.apply { this.explicitReceiver = explicitReceiver - for (typeArgument in expression.typeArguments) { - typeArguments += typeArgument.convert() - } + typeArguments.appendTypeArguments(expression.typeArguments) }.build() } @@ -2537,6 +2534,12 @@ open class RawFirBuilder( source = expression.toFirSourceElement() } } + + private fun MutableList.appendTypeArguments(args: List) { + for (typeArgument in args) { + this += typeArgument.convert() + } + } } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index 0a542246005..cb9c70bd2b6 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -555,7 +555,7 @@ class FirCallResolver( explicitReceiver = null, annotation.argumentList, isImplicitInvoke = false, - typeArguments = emptyList(), + typeArguments = annotation.typeArguments, session, components.file, components.containingDeclarations diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotation.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotation.kt index 55657f031c8..19b3e480e6d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotation.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotation.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.expressions import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -23,6 +24,7 @@ abstract class FirAnnotation : FirExpression() { abstract val useSiteTarget: AnnotationUseSiteTarget? abstract val annotationTypeRef: FirTypeRef abstract val argumentMapping: FirAnnotationArgumentMapping + abstract val typeArguments: List override fun accept(visitor: FirVisitor, data: D): R = visitor.visitAnnotation(this, data) @@ -34,7 +36,11 @@ abstract class FirAnnotation : FirExpression() { abstract fun replaceArgumentMapping(newArgumentMapping: FirAnnotationArgumentMapping) + abstract fun replaceTypeArguments(newTypeArguments: List) + abstract override fun transformAnnotations(transformer: FirTransformer, data: D): FirAnnotation abstract fun transformAnnotationTypeRef(transformer: FirTransformer, data: D): FirAnnotation + + abstract fun transformTypeArguments(transformer: FirTransformer, data: D): FirAnnotation } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt index f75a6647997..c87e42bb26c 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/FirAnnotationCall.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -23,6 +24,7 @@ abstract class FirAnnotationCall : FirAnnotation(), FirCall, FirResolvable { abstract override val annotations: List abstract override val useSiteTarget: AnnotationUseSiteTarget? abstract override val annotationTypeRef: FirTypeRef + abstract override val typeArguments: List abstract override val argumentList: FirArgumentList abstract override val calleeReference: FirReference abstract override val argumentMapping: FirAnnotationArgumentMapping @@ -35,6 +37,8 @@ abstract class FirAnnotationCall : FirAnnotation(), FirCall, FirResolvable { abstract override fun replaceTypeRef(newTypeRef: FirTypeRef) + abstract override fun replaceTypeArguments(newTypeArguments: List) + abstract override fun replaceArgumentList(newArgumentList: FirArgumentList) abstract override fun replaceCalleeReference(newCalleeReference: FirReference) @@ -45,5 +49,7 @@ abstract class FirAnnotationCall : FirAnnotation(), FirCall, FirResolvable { abstract override fun transformAnnotationTypeRef(transformer: FirTransformer, data: D): FirAnnotationCall + abstract override fun transformTypeArguments(transformer: FirTransformer, data: D): FirAnnotationCall + abstract override fun transformCalleeReference(transformer: FirTransformer, data: D): FirAnnotationCall } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt index c1938ff4e67..4c8c5624537 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationBuilder.kt @@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.expressions.FirAnnotationArgumentMapping import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationImpl +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -28,6 +29,7 @@ class FirAnnotationBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder var useSiteTarget: AnnotationUseSiteTarget? = null lateinit var annotationTypeRef: FirTypeRef lateinit var argumentMapping: FirAnnotationArgumentMapping + val typeArguments: MutableList = mutableListOf() override fun build(): FirAnnotation { return FirAnnotationImpl( @@ -35,6 +37,7 @@ class FirAnnotationBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder useSiteTarget, annotationTypeRef, argumentMapping, + typeArguments, ) } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt index 0d1b645c566..f983845b05d 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/builder/FirAnnotationCallBuilder.kt @@ -20,6 +20,7 @@ import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder import org.jetbrains.kotlin.fir.expressions.impl.FirAnnotationCallImpl import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyAnnotationArgumentMapping import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl import org.jetbrains.kotlin.fir.visitors.* @@ -34,6 +35,7 @@ class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, override var source: KtSourceElement? = null var useSiteTarget: AnnotationUseSiteTarget? = null var annotationTypeRef: FirTypeRef = FirImplicitTypeRefImpl(null) + val typeArguments: MutableList = mutableListOf() override var argumentList: FirArgumentList = FirEmptyArgumentList lateinit var calleeReference: FirReference var argumentMapping: FirAnnotationArgumentMapping = FirEmptyAnnotationArgumentMapping @@ -43,6 +45,7 @@ class FirAnnotationCallBuilder : FirCallBuilder, FirAnnotationContainerBuilder, source, useSiteTarget, annotationTypeRef, + typeArguments, argumentList, calleeReference, argumentMapping, diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt index 9b1ae5807f6..e792d433f84 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationCallImpl.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationArgumentMapping import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirArgumentList import org.jetbrains.kotlin.fir.references.FirReference +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -24,6 +25,7 @@ internal class FirAnnotationCallImpl( override val source: KtSourceElement?, override val useSiteTarget: AnnotationUseSiteTarget?, override var annotationTypeRef: FirTypeRef, + override val typeArguments: MutableList, override var argumentList: FirArgumentList, override var calleeReference: FirReference, override var argumentMapping: FirAnnotationArgumentMapping, @@ -33,12 +35,14 @@ internal class FirAnnotationCallImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { annotationTypeRef.accept(visitor, data) + typeArguments.forEach { it.accept(visitor, data) } argumentList.accept(visitor, data) calleeReference.accept(visitor, data) } override fun transformChildren(transformer: FirTransformer, data: D): FirAnnotationCallImpl { transformAnnotationTypeRef(transformer, data) + transformTypeArguments(transformer, data) argumentList = argumentList.transform(transformer, data) transformCalleeReference(transformer, data) return this @@ -53,6 +57,11 @@ internal class FirAnnotationCallImpl( return this } + override fun transformTypeArguments(transformer: FirTransformer, data: D): FirAnnotationCallImpl { + typeArguments.transformInplace(transformer, data) + return this + } + override fun transformCalleeReference(transformer: FirTransformer, data: D): FirAnnotationCallImpl { calleeReference = calleeReference.transform(transformer, data) return this @@ -60,6 +69,11 @@ internal class FirAnnotationCallImpl( override fun replaceTypeRef(newTypeRef: FirTypeRef) {} + override fun replaceTypeArguments(newTypeArguments: List) { + typeArguments.clear() + typeArguments.addAll(newTypeArguments) + } + override fun replaceArgumentList(newArgumentList: FirArgumentList) { argumentList = newArgumentList } diff --git a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationImpl.kt b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationImpl.kt index 82d3666d02b..b110af7378b 100644 --- a/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationImpl.kt +++ b/compiler/fir/tree/gen/org/jetbrains/kotlin/fir/expressions/impl/FirAnnotationImpl.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.KtSourceElement import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.fir.expressions.FirAnnotation import org.jetbrains.kotlin.fir.expressions.FirAnnotationArgumentMapping +import org.jetbrains.kotlin.fir.types.FirTypeProjection import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.visitors.* @@ -22,6 +23,7 @@ internal class FirAnnotationImpl( override val useSiteTarget: AnnotationUseSiteTarget?, override var annotationTypeRef: FirTypeRef, override var argumentMapping: FirAnnotationArgumentMapping, + override val typeArguments: MutableList, ) : FirAnnotation() { override val typeRef: FirTypeRef get() = annotationTypeRef override val annotations: List get() = emptyList() @@ -29,11 +31,13 @@ internal class FirAnnotationImpl( override fun acceptChildren(visitor: FirVisitor, data: D) { annotationTypeRef.accept(visitor, data) argumentMapping.accept(visitor, data) + typeArguments.forEach { it.accept(visitor, data) } } override fun transformChildren(transformer: FirTransformer, data: D): FirAnnotationImpl { transformAnnotationTypeRef(transformer, data) argumentMapping = argumentMapping.transform(transformer, data) + transformTypeArguments(transformer, data) return this } @@ -46,9 +50,19 @@ internal class FirAnnotationImpl( return this } + override fun transformTypeArguments(transformer: FirTransformer, data: D): FirAnnotationImpl { + typeArguments.transformInplace(transformer, data) + return this + } + override fun replaceTypeRef(newTypeRef: FirTypeRef) {} override fun replaceArgumentMapping(newArgumentMapping: FirAnnotationArgumentMapping) { argumentMapping = newArgumentMapping } + + override fun replaceTypeArguments(newTypeArguments: List) { + typeArguments.clear() + typeArguments.addAll(newTypeArguments) + } } diff --git a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt index ab07ba34c33..2b84bd79779 100644 --- a/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt +++ b/compiler/fir/tree/tree-generator/src/org/jetbrains/kotlin/fir/tree/generator/NodeConfigurator.kt @@ -458,6 +458,7 @@ object NodeConfigurator : AbstractFieldConfigurator(FirTreeBuild +field("useSiteTarget", annotationUseSiteTargetType, nullable = true) +field("annotationTypeRef", typeRef).withTransform() +field("argumentMapping", annotationArgumentMapping, withReplace = true) + +typeArguments.withTransform() } annotationCall.configure { diff --git a/compiler/testData/codegen/box/annotations/genericAnnotations.kt b/compiler/testData/codegen/box/annotations/genericAnnotations.kt index a15ce319a16..1f297d6ced8 100644 --- a/compiler/testData/codegen/box/annotations/genericAnnotations.kt +++ b/compiler/testData/codegen/box/annotations/genericAnnotations.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// FIR status: generic annotation aren't supported in FIR inference yet; see also KT-46967 // MODULE: lib // FILE: l1.kt package ann diff --git a/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt b/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt new file mode 100644 index 00000000000..7c35a395d45 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt @@ -0,0 +1,8 @@ +// FIR_IDENTICAL +// ISSUE: KT-48444 + +annotation class Foo(val s: String) + +@Foo("") +fun foo() { +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.txt b/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.txt new file mode 100644 index 00000000000..ea359aecdb2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.txt @@ -0,0 +1,11 @@ +package + +@Foo(s = "") public fun foo(): kotlin.Unit + +public final annotation class Foo : kotlin.Annotation { + public constructor Foo(/*0*/ s: kotlin.String) + public final val s: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.ir.txt b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.ir.txt new file mode 100644 index 00000000000..3d98bc18a9b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.ir.txt @@ -0,0 +1,244 @@ +FILE fqName:ann fileName:/genericAnnotationClasses.kt + CLASS ANNOTATION_CLASS name:Test1 modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.Test1 + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:ann.Test1 [primary] + VALUE_PARAMETER name:x index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Test1 modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: kotlin.Int declared in ann.Test1.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:ann.Test1) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:ann.Test1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ann.Test1' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': ann.Test1 declared in ann.Test1.' type=ann.Test1 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS ANNOTATION_CLASS name:Test2 modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.Test2 + TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any] reified:false + TYPE_PARAMETER name:T2 index:1 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (x:kotlin.Int) returnType:ann.Test2 [primary] + VALUE_PARAMETER name:x index:0 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Test2 modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: kotlin.Int declared in ann.Test2.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:ann.Test2) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:ann.Test2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ann.Test2' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': ann.Test2 declared in ann.Test2.' type=ann.Test2 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:I modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.I + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS ANNOTATION_CLASS name:Test3 modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.Test3 + TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?] reified:false + TYPE_PARAMETER name:T2 index:1 variance: superTypes:[ann.I] reified:false + CONSTRUCTOR visibility:public <> (x:ann.Test1>) returnType:ann.Test3 [primary] + VALUE_PARAMETER name:x index:0 type:ann.Test1> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Test3 modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:ann.Test1> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: ann.Test1> declared in ann.Test3.' type=ann.Test1> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:ann.Test3) returnType:ann.Test1> + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:ann.Test3 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): ann.Test1> declared in ann.Test3' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:ann.Test1> visibility:private [final]' type=ann.Test1> origin=null + receiver: GET_VAR ': ann.Test3 declared in ann.Test3.' type=ann.Test3 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[ann.I] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.C + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> () returnType:ann.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[ann.I]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in ann.I + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in ann.I + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in ann.I + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS ANNOTATION_CLASS name:Test4 modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.Test4 + CONSTRUCTOR visibility:public <> (x:kotlin.Array>>) returnType:ann.Test4 [primary] + VALUE_PARAMETER name:x index:0 type:kotlin.Array>> + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Test4 modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Array>> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'x: kotlin.Array>> declared in ann.Test4.' type=kotlin.Array>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:ann.Test4) returnType:kotlin.Array>> + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:ann.Test4 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array>> declared in ann.Test4' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Array>> visibility:private [final]' type=kotlin.Array>> origin=null + receiver: GET_VAR ': ann.Test4 declared in ann.Test4.' type=ann.Test4 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:ARG modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.ARG + CONSTRUCTOR visibility:public <> () returnType:ann.ARG [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:ARG modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS ANNOTATION_CLASS name:Test5 modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.Test5 + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (xs:kotlin.Array>>) returnType:ann.Test5 [primary] + VALUE_PARAMETER name:xs index:0 type:kotlin.Array>> varargElementType:ann.Test3> [vararg] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Test5 modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + PROPERTY name:xs visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array>> visibility:private [final] + EXPRESSION_BODY + GET_VAR 'xs: kotlin.Array>> [vararg] declared in ann.Test5.' type=kotlin.Array>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:ann.Test5) returnType:kotlin.Array>> + correspondingProperty: PROPERTY name:xs visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:ann.Test5 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Array>> declared in ann.Test5' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:xs type:kotlin.Array>> visibility:private [final]' type=kotlin.Array>> origin=null + receiver: GET_VAR ': ann.Test5 declared in ann.Test5.' type=ann.Test5 origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:CC modality:FINAL visibility:public superTypes:[kotlin.Any] + annotations: + Test1(x = '42') + Test2(x = '38') + Test3(x = Test1>>(x = '39')) + Test4(x = [Test3(x = Test1(x = '40')), Test3(x = Test1(x = '50')), Test3(x = Test1(x = '60'))]) + Test5(xs = [Test3>(x = Test1>>(x = '70')), Test3>(x = Test1>>(x = '80'))]) + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:ann.CC + CONSTRUCTOR visibility:public <> () returnType:ann.CC [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:CC modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.kt.txt b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.kt.txt new file mode 100644 index 00000000000..797e3b1fa1d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.fir.kt.txt @@ -0,0 +1,102 @@ +package ann + +open annotation class Test1 : Annotation { + constructor(x: Int) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Int + field = x + get + +} + +open annotation class Test2 : Annotation { + constructor(x: Int = 0) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Int + field = x + get + +} + +interface I { + +} + +open annotation class Test3> : Annotation { + constructor(x: Test1>) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Test1> + field = x + get + +} + +class C : I { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +open annotation class Test4 : Annotation { + constructor(x: Array>>) /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Array>> + field = x + get + +} + +class ARG { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +open annotation class Test5 : Annotation { + constructor(vararg xs: Test3>) /* primary */ { + super/*Any*/() + /* () */ + + } + + val xs: Array>> + field = xs + get + +} + +@Test1(x = 42) +@Test2(x = 38) +@Test3(x = Test1>>(x = 39)) +@Test4(x = [Test3(x = Test1(x = 40)), Test3(x = Test1(x = 50)), Test3(x = Test1(x = 60))]) +@Test5(xs = [Test3>(x = Test1>>(x = 70)), Test3>(x = Test1>>(x = 80))]) +class CC { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} diff --git a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.kt b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.kt index 3e7effb8c96..6299b96baf5 100644 --- a/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.kt +++ b/compiler/testData/ir/irText/declarations/annotations/genericAnnotationClasses.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR - package ann annotation class Test1(val x: Int) diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index e912df9b5d2..decbca339ee 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -1452,6 +1452,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); } + @Test + @TestMetadata("typeArgumentsInAnnotation.kt") + public void testTypeArgumentsInAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/typeArgumentsInAnnotation.kt"); + } + @Test @TestMetadata("typeParameterAsAnnotation.kt") public void testTypeParameterAsAnnotation() throws Exception { diff --git a/plugins/parcelize/parcelize-compiler/testData/box/customParcelerScoping.kt b/plugins/parcelize/parcelize-compiler/testData/box/customParcelerScoping.kt index a7513aa8e9f..81df3500cde 100644 --- a/plugins/parcelize/parcelize-compiler/testData/box/customParcelerScoping.kt +++ b/plugins/parcelize/parcelize-compiler/testData/box/customParcelerScoping.kt @@ -1,6 +1,4 @@ // WITH_STDLIB -// fir doesn't support annotations with type arguments -// IGNORE_BACKEND_FIR: JVM_IR @file:JvmName("TestKt") package test diff --git a/plugins/parcelize/parcelize-compiler/testData/box/customSerializerBoxing.kt b/plugins/parcelize/parcelize-compiler/testData/box/customSerializerBoxing.kt index 28304dfdda3..4bffe0c63bc 100644 --- a/plugins/parcelize/parcelize-compiler/testData/box/customSerializerBoxing.kt +++ b/plugins/parcelize/parcelize-compiler/testData/box/customSerializerBoxing.kt @@ -1,6 +1,4 @@ // WITH_STDLIB -// fir doesn't support annotations with type arguments -// IGNORE_BACKEND_FIR: JVM_IR @file:JvmName("TestKt") package test diff --git a/plugins/parcelize/parcelize-compiler/testData/box/customSerializerWriteWith.kt b/plugins/parcelize/parcelize-compiler/testData/box/customSerializerWriteWith.kt index 2a7565c39b5..365f7636e48 100644 --- a/plugins/parcelize/parcelize-compiler/testData/box/customSerializerWriteWith.kt +++ b/plugins/parcelize/parcelize-compiler/testData/box/customSerializerWriteWith.kt @@ -2,8 +2,6 @@ // See KT-38107 // The JVM backend is missing support for custom parcelers in List // WITH_STDLIB -// fir doesn't support annotations with type arguments -// IGNORE_BACKEND_FIR: JVM_IR @file:JvmName("TestKt") package test diff --git a/plugins/parcelize/parcelize-compiler/testData/box/kt46567.kt b/plugins/parcelize/parcelize-compiler/testData/box/kt46567.kt index 49796863122..1800221f2e6 100644 --- a/plugins/parcelize/parcelize-compiler/testData/box/kt46567.kt +++ b/plugins/parcelize/parcelize-compiler/testData/box/kt46567.kt @@ -1,6 +1,4 @@ // WITH_STDLIB -// fir doesn't support annotations with type arguments -// IGNORE_BACKEND_FIR: JVM_IR @file:JvmName("TestKt") package test diff --git a/plugins/parcelize/parcelize-compiler/testData/diagnostics/customParcelers.fir.kt b/plugins/parcelize/parcelize-compiler/testData/diagnostics/customParcelers.fir.kt index 2167b5ef666..0e856f4efa3 100644 --- a/plugins/parcelize/parcelize-compiler/testData/diagnostics/customParcelers.fir.kt +++ b/plugins/parcelize/parcelize-compiler/testData/diagnostics/customParcelers.fir.kt @@ -19,27 +19,27 @@ class StringClassParceler : Parceler { override fun String.write(parcel: Parcel, flags: Int) = TODO() } -@TypeParceler -class MissingParcelizeAnnotation(val a: @WriteWith String) +@TypeParceler +class MissingParcelizeAnnotation(val a: @WriteWith String) @Parcelize -@TypeParceler -class ShouldBeClass(val a: @WriteWith String) : Parcelable +@TypeParceler +class ShouldBeClass(val a: @WriteWith String) : Parcelable @Parcelize class Test( - val a: @WriteWith Int, - val b: @WriteWith String, - val c: @WriteWith CharSequence, - val d: @WriteWith String, - val e: @WriteWith CharSequence + val a: @WriteWith Int, + val b: @WriteWith String, + val c: @WriteWith CharSequence, + val d: @WriteWith String, + val e: @WriteWith CharSequence ) : Parcelable @Parcelize -@TypeParceler -class Test2(@TypeParceler val a: String) : Parcelable +@TypeParceler +class Test2(@TypeParceler val a: String) : Parcelable @Parcelize -@TypeParceler -@TypeParceler +@TypeParceler +@TypeParceler class Test3(val a: String) : Parcelable diff --git a/plugins/parcelize/parcelize-compiler/testData/diagnostics/deprecatedAnnotations.fir.kt b/plugins/parcelize/parcelize-compiler/testData/diagnostics/deprecatedAnnotations.fir.kt index 3863793bda5..3d7a333fdc7 100644 --- a/plugins/parcelize/parcelize-compiler/testData/diagnostics/deprecatedAnnotations.fir.kt +++ b/plugins/parcelize/parcelize-compiler/testData/diagnostics/deprecatedAnnotations.fir.kt @@ -22,11 +22,11 @@ object Parceler2 : Parceler> { } @Parcelize -@TypeParceler +@TypeParceler data class Test( val a: String, - val b: @WriteWith String, - val c: @WriteWith List<@WriteWith String> + val b: @WriteWith String, + val c: @WriteWith List<@WriteWith String> ) : Parcelable { @IgnoredOnParcel val x by lazy { "foo" }