diff --git a/compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt b/compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt index 710d7d92063..c5f8a280ca4 100644 --- a/compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt +++ b/compiler/fir/analysis-tests/testData/resolve/annotationUsedAsAnnotationArgument.kt @@ -12,8 +12,8 @@ annotation class Ann2 @Retention(AnnotationRetention.SOURCE) annotation class Ann3(val arg: Int, val s: String) -@Ann3( +@Ann3( @Ann3( @Ann 5, "" ) @Ann2 1, "" -) val a = 0 \ No newline at end of file +) val a = 0 diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotationWithReturn.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotationWithReturn.kt index 9bdb75ab1c0..21f8a2cef26 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotationWithReturn.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotationWithReturn.kt @@ -1,5 +1,5 @@ // Should be something like TYPE_MISMATCH here -@file:Some(return x) +@file:Some(return x) const val x = 42 diff --git a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.kt b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.kt index bdf08d2430a..fa8ae613c71 100644 --- a/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.kt +++ b/compiler/fir/analysis-tests/testData/resolve/expresssions/annotations.kt @@ -7,7 +7,7 @@ annotation class MyAnn fun bar(x: Int) {} fun foo() { - @MyAnn + @MyAnn val x: Int @MyAnn x = @MyAnn 42 diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.fir.txt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.fir.txt index 637874eec20..fa6dc41e51c 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.fir.txt @@ -1,5 +1,5 @@ FILE: RedundantSetterParameterTypeChecker.kt - @R|kotlin/annotation/Target|(vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.CLASS|)) public final annotation class Ann : R|kotlin/Annotation| { + @R|kotlin/annotation/Target|(vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.VALUE_PARAMETER|)) public final annotation class Ann : R|kotlin/Annotation| { public constructor(): R|Ann| { super() } diff --git a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.kt b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.kt index c7a61f7cd1e..779a40a56b3 100644 --- a/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.kt +++ b/compiler/fir/analysis-tests/testData/resolve/extendedCheckers/RedundantSetterParameterTypeChecker.kt @@ -1,5 +1,5 @@ -@Target(AnnotationTarget.CLASS) +@Target(AnnotationTarget.VALUE_PARAMETER) annotation class Ann var x: Int diff --git a/compiler/fir/analysis-tests/testData/resolve/multifile/Annotations.kt b/compiler/fir/analysis-tests/testData/resolve/multifile/Annotations.kt index 721194e5944..edf9d585c88 100644 --- a/compiler/fir/analysis-tests/testData/resolve/multifile/Annotations.kt +++ b/compiler/fir/analysis-tests/testData/resolve/multifile/Annotations.kt @@ -41,6 +41,6 @@ class Second(val y: Char) : @WithInt(0) First() { constructor(): this('\n') } -@WithInt(24) -@VeryComplex(3.14f, 6.67e-11, false, 123456789012345L, null) +@WithInt(24) +@VeryComplex(3.14f, 6.67e-11, false, 123456789012345L, null) typealias Third = @Simple Second diff --git a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt index 09777cb79e0..feb8f67cf19 100644 --- a/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt +++ b/compiler/fir/checkers/checkers-component-generator/src/org/jetbrains/kotlin/fir/checkers/generator/diagnostics/FirDiagnosticsList.kt @@ -176,6 +176,10 @@ object DIAGNOSTICS_LIST : DiagnosticList() { val WRONG_ANNOTATION_TARGET by error { parameter("actualTarget") } + val WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET by error { + parameter("actualTarget") + parameter("useSiteTarget") + } } val EXPOSED_VISIBILITY by object : DiagnosticGroup("Exposed visibility") { diff --git a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt index d6e05365252..546cc0e7ce6 100644 --- a/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt +++ b/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt @@ -180,6 +180,7 @@ object FirErrors { val ANNOTATION_ON_SUPERCLASS by error0() val RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION by error0() val WRONG_ANNOTATION_TARGET by error1() + val WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET by error2() // Exposed visibility val EXPOSED_TYPEALIAS_EXPANDED_TYPE by error3(SourceElementPositioningStrategies.DECLARATION_NAME) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirAnnotationHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirAnnotationHelpers.kt index 32dc8697a9f..9737c0fe220 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirAnnotationHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirAnnotationHelpers.kt @@ -79,7 +79,8 @@ fun FirAnnotationCall.findSingleArgumentByName(name: Name): FirExpression? { return argumentMapping.keys.firstOrNull()?.takeIf { argumentMapping[it]?.name == name } } // NB: we have to consider both cases, because deserializer does not create argument mapping - val firstArgument = argumentList.arguments.firstOrNull() as? FirNamedArgumentExpression ?: return null + val arguments = argumentList.arguments + val firstArgument = arguments.firstOrNull() as? FirNamedArgumentExpression ?: return arguments.singleOrNull() return firstArgument.takeIf { it.name == name }?.expression } diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt index b42ad46b5d9..1b6a34da66c 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/declaration/FirAnnotationChecker.kt @@ -5,18 +5,22 @@ package org.jetbrains.kotlin.fir.analysis.checkers.declaration +import org.jetbrains.kotlin.descriptors.ClassKind +import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget +import org.jetbrains.kotlin.fir.FirFakeSourceElementKind import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext import org.jetbrains.kotlin.fir.analysis.checkers.context.findClosest -import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter -import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors -import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn -import org.jetbrains.kotlin.fir.declarations.FirAnnotatedDeclaration -import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.analysis.checkers.getAllowedAnnotationTargets +import org.jetbrains.kotlin.fir.analysis.diagnostics.* +import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.argumentMapping import org.jetbrains.kotlin.fir.resolve.fqName import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.StandardClassIds +import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.resolve.AnnotationTargetList +import org.jetbrains.kotlin.resolve.AnnotationTargetLists object FirAnnotationChecker : FirAnnotatedDeclarationChecker() { private val deprecatedClassId = FqName("kotlin.Deprecated") @@ -37,33 +41,158 @@ object FirAnnotationChecker : FirAnnotatedDeclarationChecker() { } else if (fqName == deprecatedSinceKotlinClassId) { deprecatedSinceKotlinCall = annotation } + withSuppressedDiagnostics(annotation, context) { + checkAnnotationTarget(declaration, annotation, context, reporter) + } + } + if (deprecatedSinceKotlinCall != null) { + withSuppressedDiagnostics(deprecatedSinceKotlinCall, context) { + checkDeprecatedCalls(deprecatedSinceKotlinCall, deprecatedCall, context, reporter) + } + } + } + + private fun checkAnnotationTarget( + declaration: FirAnnotatedDeclaration, + annotation: FirAnnotationCall, + context: CheckerContext, + reporter: DiagnosticReporter + ) { + if (declaration is FirValueParameter && declaration.source?.hasValOrVar() == true) { + // This will be checked later as property + return + } + val actualTargets = getActualTargetList(declaration) + val applicableTargets = annotation.getAllowedAnnotationTargets(context.session) + val useSiteTarget = annotation.useSiteTarget + + fun check(targets: List) = targets.any { + it in applicableTargets && (useSiteTarget == null || KotlinTarget.USE_SITE_MAPPING[useSiteTarget] == it) } - if (deprecatedSinceKotlinCall != null) { - val closestFirFile = context.findClosest() - if (closestFirFile != null && !closestFirFile.packageFqName.startsWith(StandardClassIds.BASE_KOTLIN_PACKAGE.shortName())) { - reporter.reportOn( - deprecatedSinceKotlinCall.source, - FirErrors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE, - context - ) - } + fun checkWithUseSiteTargets(): Boolean { + if (useSiteTarget == null) return false - if (deprecatedCall == null) { - reporter.reportOn(deprecatedSinceKotlinCall.source, FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, context) - } else { - val argumentMapping = deprecatedCall.argumentMapping ?: return - for (value in argumentMapping.values) { - if (value.name.identifier == "level") { - reporter.reportOn( - deprecatedSinceKotlinCall.source, - FirErrors.DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, - context - ) - break - } + val useSiteMapping = KotlinTarget.USE_SITE_MAPPING[useSiteTarget] + return actualTargets.onlyWithUseSiteTarget.any { it in applicableTargets && it == useSiteMapping } + } + + if (check(actualTargets.defaultTargets) || check(actualTargets.canBeSubstituted) || checkWithUseSiteTargets()) { + return + } + + val targetDescription = actualTargets.defaultTargets.firstOrNull()?.description ?: "unidentified target" + if (useSiteTarget != null) { + reporter.reportOn( + annotation.source, + FirErrors.WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET, + targetDescription, + useSiteTarget.renderName, + context + ) + } else { + reporter.reportOn( + annotation.source, + FirErrors.WRONG_ANNOTATION_TARGET, + targetDescription, + context + ) + } + } + + private fun checkDeprecatedCalls( + deprecatedSinceKotlinCall: FirAnnotationCall, + deprecatedCall: FirAnnotationCall?, + context: CheckerContext, + reporter: DiagnosticReporter + ) { + val closestFirFile = context.findClosest() + if (closestFirFile != null && !closestFirFile.packageFqName.startsWith(StandardClassIds.BASE_KOTLIN_PACKAGE.shortName())) { + reporter.reportOn( + deprecatedSinceKotlinCall.source, + FirErrors.DEPRECATED_SINCE_KOTLIN_OUTSIDE_KOTLIN_SUBPACKAGE, + context + ) + } + + if (deprecatedCall == null) { + reporter.reportOn(deprecatedSinceKotlinCall.source, FirErrors.DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, context) + } else { + val argumentMapping = deprecatedCall.argumentMapping ?: return + for (value in argumentMapping.values) { + if (value.name.identifier == "level") { + reporter.reportOn( + deprecatedSinceKotlinCall.source, + FirErrors.DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, + context + ) + break } } } } -} \ No newline at end of file + + private fun getActualTargetList(annotated: FirDeclaration): AnnotationTargetList { + return when (annotated) { + is FirRegularClass -> { + AnnotationTargetList( + KotlinTarget.classActualTargets(annotated.classKind, annotated.isInner, annotated.isCompanion, annotated.isLocal) + ) + } + is KtDestructuringDeclarationEntry -> TargetLists.T_LOCAL_VARIABLE + is FirProperty -> { + when { + annotated.isLocal -> + if (annotated.source?.kind == FirFakeSourceElementKind.DesugaredComponentFunctionCall) { + TargetLists.T_DESTRUCTURING_DECLARATION + } else { + TargetLists.T_LOCAL_VARIABLE + } + annotated.symbol.callableId.classId != null -> + if (annotated.source?.kind == FirFakeSourceElementKind.PropertyFromParameter) { + TargetLists.T_VALUE_PARAMETER_WITH_VAL + } else { + TargetLists.T_MEMBER_PROPERTY(annotated.hasBackingField, annotated.delegate != null) + } + else -> + TargetLists.T_TOP_LEVEL_PROPERTY(annotated.hasBackingField, annotated.delegate != null) + } + } + is FirValueParameter -> TargetLists.T_VALUE_PARAMETER_WITHOUT_VAL + is FirConstructor -> TargetLists.T_CONSTRUCTOR + is FirAnonymousFunction -> { + TargetLists.T_FUNCTION_EXPRESSION + } + is FirSimpleFunction -> { + when { + annotated.isLocal -> TargetLists.T_LOCAL_FUNCTION + annotated.symbol.callableId.classId != null -> TargetLists.T_MEMBER_FUNCTION + else -> TargetLists.T_TOP_LEVEL_FUNCTION + } + } + is FirTypeAlias -> TargetLists.T_TYPEALIAS + is FirPropertyAccessor -> if (annotated.isGetter) TargetLists.T_PROPERTY_GETTER else TargetLists.T_PROPERTY_SETTER + is FirFile -> TargetLists.T_FILE + is FirTypeParameter -> TargetLists.T_TYPE_PARAMETER + is FirAnonymousInitializer -> TargetLists.T_INITIALIZER + is KtDestructuringDeclaration -> TargetLists.T_DESTRUCTURING_DECLARATION + is KtLambdaExpression -> TargetLists.T_FUNCTION_LITERAL + is FirAnonymousObject -> + if (annotated.source?.kind == FirFakeSourceElementKind.EnumInitializer) { + AnnotationTargetList( + KotlinTarget.classActualTargets( + ClassKind.ENUM_ENTRY, + isInnerClass = false, + isCompanionObject = false, + isLocalClass = false + ) + ) + } else { + TargetLists.T_OBJECT_LITERAL + } + else -> TargetLists.EMPTY + } + } +} + +private typealias TargetLists = AnnotationTargetLists diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt index f79b1ea5891..366c9a39008 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/collectors/components/DeclarationCheckersDiagnosticComponent.kt @@ -51,15 +51,15 @@ class DeclarationCheckersDiagnosticComponent( } override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: CheckerContext) { - checkers.allBasicDeclarationCheckers.check(anonymousFunction, data, reporter) + checkers.allAnnotatedDeclarationCheckers.check(anonymousFunction, data, reporter) } override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor, data: CheckerContext) { - checkers.allBasicDeclarationCheckers.check(propertyAccessor, data, reporter) + checkers.allAnnotatedDeclarationCheckers.check(propertyAccessor, data, reporter) } override fun visitValueParameter(valueParameter: FirValueParameter, data: CheckerContext) { - checkers.allBasicDeclarationCheckers.check(valueParameter, data, reporter) + checkers.allAnnotatedDeclarationCheckers.check(valueParameter, data, reporter) } override fun visitTypeParameter(typeParameter: FirTypeParameter, data: CheckerContext) { diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt index a5f74505e62..e34897f29af 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/FirDefaultErrorMessages.kt @@ -329,6 +329,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAR_ANNOTATION_PA import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAR_OVERRIDDEN_BY_VAL import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VAR_TYPE_MISMATCH_ON_OVERRIDE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_ANNOTATION_TARGET +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_GETTER_RETURN_TYPE import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_INVOCATION_KIND import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_MODIFIER_TARGET @@ -478,6 +479,12 @@ class FirDefaultErrorMessages : DefaultErrorMessages.Extension { ) map.put(ANNOTATION_ON_SUPERCLASS, "Annotations on superclass are meaningless") map.put(WRONG_ANNOTATION_TARGET, "This annotation is not applicable to target ''{0}''", TO_STRING); + map.put( + WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET, + "This annotation is not applicable to target ''{0}'' and use site target ''@{1}''", + TO_STRING, + TO_STRING + ); // Exposed visibility group // # map.put( diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt index a0ce821693b..f0d2f53d92d 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForClassTypeParameter.fir.kt @@ -1,10 +1,10 @@ annotation class A1 annotation class A2(val some: Int = 12) -class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { - class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { +class TopLevelClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { + class InnerClass<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> { fun test() { - class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> + class InFun<@A1 @A2(3) @A2 @A1(12) @A2("Test") T> } } } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt index 37fb73fef5c..ac4dd679e26 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationForFunctionTypeParameter.fir.kt @@ -1,12 +1,12 @@ annotation class A1 annotation class A2(val some: Int = 12) -fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> topFun() = 12 +fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> topFun() = 12 class SomeClass { - fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> method() = 12 + fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> method() = 12 fun foo() { - fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> innerFun() = 12 + fun <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> innerFun() = 12 } } diff --git a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt index 1e0c7ae0af2..ce71334dc83 100644 --- a/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/AnnotationsForPropertyTypeParameter.fir.kt @@ -3,10 +3,10 @@ annotation class A1 annotation class A2(val some: Int = 12) -val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.topProp: Int get() = 12 +val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.topProp: Int get() = 12 class SomeClass { - val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.field: Int get() = 12 + val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> T.field: Int get() = 12 fun foo() { val <@A1 @A2(3) @A2 @A1(12) @A2("Test") T> localVal = 12 diff --git a/compiler/testData/diagnostics/tests/annotations/options/multiDeclaration.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/multiDeclaration.fir.kt index 80ffcfcb864..0f641a3b285 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/multiDeclaration.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/multiDeclaration.fir.kt @@ -2,6 +2,6 @@ annotation class My data class Pair(val a: Int, val b: Int) fun foo(): Int { - val (@My private a, @My public b) = Pair(12, 34) + val (@My private a, @My public b) = Pair(12, 34) return a + b } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/setterParam.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/setterParam.fir.kt index 89d774979d6..67db8a303ef 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/setterParam.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/setterParam.fir.kt @@ -5,4 +5,4 @@ annotation class Ann var x: Int get() = 1 - set(@Ann private x) { } \ No newline at end of file + set(@Ann private x) { } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.fir.kt index 47f5a243a6e..b0eee1802be 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/accessors.fir.kt @@ -8,9 +8,9 @@ annotation class smartset annotation class base class My(x: Int) { - @smartget var y = x + @smartget var y = x @base @smartget @smartset get @base @smartget @smartset set - @base @smartget @smartset fun foo() = y + @base @smartget @smartset fun foo() = y } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.fir.kt index 31b8e95d177..bc74bf27ea1 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/annotation.fir.kt @@ -2,19 +2,19 @@ @base annotation class derived -@base class correct(@base val x: Int) { - @base constructor(): this(0) +@base class correct(@base val x: Int) { + @base constructor(): this(0) } -@base enum class My { - @base FIRST, - @base SECOND +@base enum class My { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } -@base val z = 0 +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.fir.kt index fc66e1f59ce..2c87197e03d 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/classifier.fir.kt @@ -3,19 +3,19 @@ @base annotation class derived -@base class correct(@base val x: Int, @base w: @base Int) { - @base constructor(): this(0, 0) +@base class correct(@base val x: Int, @base w: @base Int) { + @base constructor(): this(0, 0) } -@base enum class My @base constructor() { - @base FIRST, - @base SECOND +@base enum class My @base constructor() { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } -@base val z = 0 +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.fir.kt index 294579bda78..8730a0d6e25 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/constructor.fir.kt @@ -1,20 +1,20 @@ @Target(AnnotationTarget.CONSTRUCTOR) annotation class base -@base annotation class derived +@base annotation class derived -@base class correct(@base val x: Int) { +@base class correct(@base val x: Int) { @base constructor(): this(0) } -@base enum class My @base constructor() { - @base FIRST, - @base SECOND +@base enum class My @base constructor() { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } -@base val z = 0 +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.fir.kt index 77b6e6a32f5..57502348611 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.fir.kt @@ -6,7 +6,7 @@ annotation class special fun transform(i: Int, tr: (Int) -> Int): Int = @base @special tr(@special i) -@base @special fun foo(i: Int): Int { +@base @special fun foo(i: Int): Int { val j = @base @special i + 1 if (j == 1) return foo(@special @base 42) return transform(@special j, @base @special { @special it * 2 }) diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt index f0a3ce8caad..0eeb8e03956 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/field.fir.kt @@ -2,32 +2,32 @@ @Target(AnnotationTarget.FIELD) annotation class Field -@Field +@Field annotation class Another @Field val x: Int = 42 -@Field +@Field val y: Int get() = 13 -@Field -abstract class My(@Field arg: Int, @Field val w: Int) { +@Field +abstract class My(@Field arg: Int, @Field val w: Int) { @Field val x: Int = arg - @Field + @Field val y: Int get() = 0 - @Field + @Field abstract val z: Int - @Field + @Field fun foo() {} - @Field + @Field val v: Int by Delegates.lazy { 42 } } @@ -36,10 +36,10 @@ enum class Your { } interface His { - @Field + @Field val x: Int - @Field + @Field val y: Int get() = 42 } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/file.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/file.fir.kt deleted file mode 100644 index fff4469146c..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/file.fir.kt +++ /dev/null @@ -1,23 +0,0 @@ -// FILE: annotation.kt - -package test - -@Target(AnnotationTarget.FILE) annotation class special - -annotation class common - -// FILE: other.kt - -@file:special - -package test - -@special class Incorrect - -// FILE: another.kt - -@file:common - -package test - -@common class Correct diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt index 1a35394f546..1c2ec6b62d4 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/file.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: annotation.kt package test diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/function.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/function.fir.kt index e64693a83d4..419a05e7b33 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/function.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/function.fir.kt @@ -1,22 +1,22 @@ @Target(AnnotationTarget.FUNCTION) annotation class base -@base annotation class derived +@base annotation class derived -@base class correct(@base val x: Int) { - @base constructor(): this(0) +@base class correct(@base val x: Int) { + @base constructor(): this(0) @base public fun baz() {} } -@base enum class My @base constructor() { - @base FIRST, - @base SECOND +@base enum class My @base constructor() { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } -@base val z = 0 \ No newline at end of file +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.fir.kt index b9cc70894c0..6e4d55e9671 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/incorrect.fir.kt @@ -1,21 +1,21 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER @Target(AnnotationTarget.INIT) annotation class incorrect -@incorrect annotation class derived +@incorrect annotation class derived -@incorrect class correct(@incorrect val x: Int, @incorrect w: @incorrect Int) { - @incorrect constructor(): this(0, 0) +@incorrect class correct(@incorrect val x: Int, @incorrect w: @incorrect Int) { + @incorrect constructor(): this(0, 0) } -@incorrect enum class My @incorrect constructor() { - @incorrect FIRST, - @incorrect SECOND +@incorrect enum class My @incorrect constructor() { + @incorrect FIRST, + @incorrect SECOND } -@incorrect fun foo(@incorrect y: @incorrect Int): Int { - @incorrect fun bar(@incorrect z: @incorrect Int) = z + 1 - @incorrect val local = bar(y) +@incorrect fun foo(@incorrect y: @incorrect Int): Int { + @incorrect fun bar(@incorrect z: @incorrect Int) = z + 1 + @incorrect val local = bar(y) return local } -@incorrect val z = @incorrect 0 +@incorrect val z = @incorrect 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/java.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/java.fir.kt index 86245ec9a5b..7a9ae6c9a06 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/java.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/java.fir.kt @@ -60,23 +60,23 @@ package test import test.AnnotationTargets.* -@base @meta @type @konstructor annotation class KMeta +@base @meta @type @konstructor annotation class KMeta -@base @meta @type @method @multiple class KClass( +@base @meta @type @method @multiple class KClass( @base @fieldann @parameter val y: @base @type Int) { - @base @multiple @fieldann @local val x = 0 + @base @multiple @fieldann @local val x = 0 @method @konstructor @type get - @base @method @multiple @konstructor - fun foo(@parameter @type i: + @base @method @multiple @konstructor + fun foo(@parameter @type i: @base @multiple Int ): @fieldann @parameter Int { - @local @base @multiple @fieldann val j = i + 1 + @local @base @multiple @fieldann val j = i + 1 @base @multiple return j } - @base @method @konstructor constructor(): this(0) + @base @method @konstructor constructor(): this(0) } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/local.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/local.fir.kt index a3b51770c7f..059684d7a2e 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/local.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/local.fir.kt @@ -1,20 +1,20 @@ @Target(AnnotationTarget.LOCAL_VARIABLE) annotation class base -@base annotation class derived +@base annotation class derived -@base class correct(@base val x: Int) { - @base constructor(): this(0) +@base class correct(@base val x: Int) { + @base constructor(): this(0) } -@base enum class My { - @base FIRST, - @base SECOND +@base enum class My { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 @base val local = bar(y) return local } -@base val z = 0 +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.fir.kt deleted file mode 100644 index a836dd98491..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -@Target(AnnotationTarget.CLASS) -annotation class base - -@Target(AnnotationTarget.ANNOTATION_CLASS) -annotation class meta - -@base class Outer { - @base @meta class Nested - - @base @meta annotation class Annotated - - fun foo() { - @base @meta class Local - } -} diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt index 57694f7a6e5..7ada78833ec 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/nested.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL @Target(AnnotationTarget.CLASS) annotation class base diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/property.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/property.fir.kt index 73fe69e8cda..d3c4c2ccf92 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/property.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/property.fir.kt @@ -1,20 +1,20 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER @Target(AnnotationTarget.PROPERTY) annotation class base -@base annotation class derived +@base annotation class derived -@base class correct(@base val x: Int, @base w: Int) { - @base constructor(): this(0, 0) +@base class correct(@base val x: Int, @base w: Int) { + @base constructor(): this(0, 0) } -@base enum class My { +@base enum class My { @base FIRST, @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/type.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/type.fir.kt deleted file mode 100644 index fddebafe484..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/type.fir.kt +++ /dev/null @@ -1,20 +0,0 @@ -@Target(AnnotationTarget.TYPE) annotation class base - -@base annotation class derived - -@base class correct(@base val x: @base Int) { - @base constructor(): this(0) -} - -@base enum class My @base constructor() { - @base FIRST, - @base SECOND -} - -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) - return local -} - -@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt index ebe9314228e..e2b3a607686 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/type.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL @Target(AnnotationTarget.TYPE) annotation class base @base annotation class derived diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.fir.kt index bb4af67b25c..991faa0f3d1 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/typeParams.fir.kt @@ -24,10 +24,10 @@ class Class2 { } -@A fun foo() {} -@A class D +@A fun foo() {} +@A class D fun foo(i: @A Int) { - @A val i = 1 + @A val i = 1 } fun test(t: @A T): T = t @@ -35,4 +35,4 @@ fun test(t: @A T): T = t @Target(AnnotationTarget.TYPE) internal annotation class C -fun <@C T> test2(t: T): T = t \ No newline at end of file +fun <@C T> test2(t: T): T = t diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.fir.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.fir.kt index 89f1de3c26d..4d17bde22a1 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/valueparam.fir.kt @@ -1,21 +1,21 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER @Target(AnnotationTarget.VALUE_PARAMETER) annotation class base -@base annotation class derived +@base annotation class derived -@base class correct(@base val x: Int, @base w: Int) { - @base constructor(): this(0, 0) +@base class correct(@base val x: Int, @base w: Int) { + @base constructor(): this(0, 0) } -@base enum class My { - @base FIRST, - @base SECOND +@base enum class My { + @base FIRST, + @base SECOND } -@base fun foo(@base y: @base Int): Int { - @base fun bar(@base z: @base Int) = z + 1 - @base val local = bar(y) +@base fun foo(@base y: @base Int): Int { + @base fun bar(@base z: @base Int) = z + 1 + @base val local = bar(y) return local } -@base val z = 0 +@base val z = 0 diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.fir.kt index 930f962015f..86067bff9d7 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.fir.kt @@ -8,26 +8,26 @@ class CustomDelegate { operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name } -@delegate:Field +@delegate:Field class SomeClass { - @delegate:Field + @delegate:Field constructor() - @delegate:Field @delegate:Prop + @delegate:Field @delegate:Prop protected val simpleProperty: String = "text" - @delegate:Field @delegate:Prop + @delegate:Field @delegate:Prop protected val delegatedProperty: String by CustomDelegate() - @delegate:Field @delegate:Prop + @delegate:Field @delegate:Prop val propertyWithCustomGetter: Int get() = 5 } -class WithPrimaryConstructor(@delegate:Field @delegate:Prop val a: String, - @param:Field @param:Prop val b: String) +class WithPrimaryConstructor(@delegate:Field @delegate:Prop val a: String, + @param:Field @param:Prop val b: String) -fun foo(@delegate:Field @delegate:Prop x: Int) = x +fun foo(@delegate:Field @delegate:Prop x: Int) = x diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.fir.kt index 006381feb39..1aae9746799 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.fir.kt @@ -6,10 +6,10 @@ class CustomDelegate { operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name } -@field:Ann +@field:Ann class SomeClass { - @field:Ann + @field:Ann constructor() @field:Ann @@ -21,13 +21,13 @@ class SomeClass { @field:Ann protected val delegatedProperty: String by CustomDelegate() - @field:Ann + @field:Ann val propertyWithCustomGetter: Int get() = 5 - @field:Ann - fun anotherFun(@field:Ann s: String) { - @field:Ann + @field:Ann + fun anotherFun(@field:Ann s: String) { + @field:Ann val localVariable = 5 } diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.fir.kt deleted file mode 100644 index 1092884e7f3..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.fir.kt +++ /dev/null @@ -1,12 +0,0 @@ -// FILE: annotations.kt -@Target(AnnotationTarget.CLASS) -public annotation class ClassAnn - -@Target(AnnotationTarget.FILE) -public annotation class FileAnn - -// FILE: 1.kt -@file:ClassAnn - -// FILE: 2.kt -@file:FileAnn \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.kt index 2a33fa83b8a..aa92ef4ca91 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FileAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // FILE: annotations.kt @Target(AnnotationTarget.CLASS) public annotation class ClassAnn diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.fir.kt deleted file mode 100644 index 343a6ccde0d..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -import kotlin.reflect.KProperty - -annotation class Ann - -class CustomDelegate { - operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name -} - -@get:Ann -class SomeClass { - - @get:Ann - constructor() - - @get:Ann - protected val simpleProperty: String = "text" - - @get:Ann - protected var mutableProperty: String = "text" - - @get:[Ann] - protected val simplePropertyWithAnnotationList: String = "text" - - @get:Ann - protected val delegatedProperty: String by CustomDelegate() - - @get:Ann - val propertyWithCustomGetter: Int - get() = 5 - - @get:Ann - fun annotationOnFunction(a: Int) = a + 5 - - fun anotherFun() { - @get:Ann - val localVariable = 5 - } - -} diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.kt index 9510423cb9e..f96c94322c0 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import kotlin.reflect.KProperty annotation class Ann diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.fir.kt index f0f7b9c9442..77d6e7a4452 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.fir.kt @@ -1,10 +1,10 @@ annotation class Ann annotation class Second -@param:Ann +@param:Ann class SomeClass { - @param:Ann + @param:Ann constructor(@param:Ann a: String) @param:Ann diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.fir.kt deleted file mode 100644 index 9142c89dbb6..00000000000 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.fir.kt +++ /dev/null @@ -1,39 +0,0 @@ -import kotlin.reflect.KProperty - -annotation class Ann -annotation class Second - -class CustomDelegate { - operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name -} - -@property:Ann -class SomeClass { - - @property:Ann - constructor(s: String) - - @property:Ann - protected val p1: String = "" - - @property:[Ann Second] - protected val p2: String = "" - - @property:Ann - protected var p3: String = "" - - @property:Ann - protected val p4: String by CustomDelegate() - - @property:Ann - var propertyWithCustomSetter: Int - get() = 5 - set(v) {} - - @property:Ann - fun anotherFun() { - @property:Ann - val localVariable = 5 - } - -} diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.kt index aa5989a5fda..b98e7981c50 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL import kotlin.reflect.KProperty annotation class Ann diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.fir.kt index 74ccbb4be01..d9b475be1eb 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.fir.kt @@ -1,9 +1,9 @@ annotation class Ann -@receiver:Ann +@receiver:Ann class SomeClass { - @receiver:Ann + @receiver:Ann constructor(@receiver:Ann a: String) @receiver:Ann diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.fir.kt index ddde82164fb..e72ded6e27e 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.fir.kt @@ -7,7 +7,7 @@ class CustomDelegate { operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {} } -@set:Ann +@set:Ann class SomeClass { @set:Ann @@ -27,7 +27,7 @@ class SomeClass { get() = 5 set(v) {} - @set:Ann + @set:Ann fun annotationOnFunction(a: Int) = a + 5 fun anotherFun() { diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.fir.kt index 9279aa0120a..a4f6646d47b 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.fir.kt @@ -7,10 +7,10 @@ class CustomDelegate { operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {} } -@setparam:Ann +@setparam:Ann class SomeClass { - @setparam:Ann + @setparam:Ann constructor() @setparam:Ann diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.fir.kt index d876193a25c..4eb44143744 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.fir.kt @@ -1,12 +1,12 @@ package bar -@file:foo +@file:foo val prop -@file:[bar baz] +@file:[bar baz] fun func() {} -@file:[baz] +@file:[baz] class C @file: diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackage.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackage.fir.kt index 026f57fa379..65b76865d77 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackage.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackage.fir.kt @@ -1,6 +1,6 @@ -@file:foo +@file:foo @foo @bar -@file:[baz] +@file:[baz] fun test() {} annotation class foo diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackageWithSimpleAnnotation.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackageWithSimpleAnnotation.fir.kt index ab22f55f577..4d51dd582c7 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackageWithSimpleAnnotation.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticWithoutPackageWithSimpleAnnotation.fir.kt @@ -1,6 +1,6 @@ -@file:foo +@file:foo @foo @bar -@file: baz +@file: baz fun test() {} annotation class foo diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_after.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_after.fir.kt index 0ea7436b026..f574d4ced6c 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_after.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_after.fir.kt @@ -1,9 +1,9 @@ // !LANGUAGE: +RestrictionOfWrongAnnotationsWithUseSiteTargetsOnTypes // !DIAGNOSTICS: -UNUSED_PARAMETER -fun test1(@file Suppress("") x: Int) {} +fun test1(@file Suppress("") x: Int) {} -@file @Suppress("") +@file @Suppress("") fun test2() {} class OnType(x: @file Suppress("") Int) diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_before.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_before.fir.kt index b67f6f53f0c..9a8f7dd76c8 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_before.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/fileAnnotationWithoutColon_before.fir.kt @@ -1,9 +1,9 @@ // !LANGUAGE: -RestrictionOfWrongAnnotationsWithUseSiteTargetsOnTypes // !DIAGNOSTICS: -UNUSED_PARAMETER -fun test1(@file Suppress("") x: Int) {} +fun test1(@file Suppress("") x: Int) {} -@file @Suppress("") +@file @Suppress("") fun test2() {} class OnType(x: @file Suppress("") Int) diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/repeatable.fir.kt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/repeatable.fir.kt index bc12a82c794..9234dcd817a 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/repeatable.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/repeatable.fir.kt @@ -45,12 +45,12 @@ annotation class fieldOrPropAnn @Target(AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.VALUE_PARAMETER) annotation class getSetAndParamAnn -public class B(@param:fieldOrPropAnn @fieldOrPropAnn val x: Int, +public class B(@param:fieldOrPropAnn @fieldOrPropAnn val x: Int, @property:fieldOrPropAnn @fieldOrPropAnn val y: Int) { @fieldOrPropAnn @field:fieldOrPropAnn val z: Int = 42 - @getSetAndParamAnn + @getSetAndParamAnn @setparam:getSetAndParamAnn var w: Int @getSetAndParamAnn @get:getSetAndParamAnn get() = 0 diff --git a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/modifiers.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/modifiers.fir.kt index c39cd83275e..18df305c7a7 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/modifiers.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/destructuringInLambdas/modifiers.fir.kt @@ -8,7 +8,7 @@ fun foo(block: (A) -> Unit) { } annotation class Ann fun bar() { - foo { (private inline a, @Ann b) -> + foo { (private inline a, @Ann b) -> a checkType { _() } b checkType { _() } } diff --git a/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.fir.kt b/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.fir.kt deleted file mode 100644 index c31ba56353d..00000000000 --- a/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.fir.kt +++ /dev/null @@ -1,15 +0,0 @@ -// WITH_RUNTIME -import kotlin.annotation.AnnotationTarget.* - -annotation class NoTarget - -@Target(CLASS) -annotation class IrrelevantTarget - -@Target(TYPEALIAS) -annotation class TypealiasTarget - -@NoTarget -@IrrelevantTarget -@TypealiasTarget -typealias Test = String \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.kt b/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.kt index 18ef6876c85..e4e9cbc55ca 100644 --- a/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.kt +++ b/compiler/testData/diagnostics/tests/typealias/annotationsOnTypeAliases.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // WITH_RUNTIME import kotlin.annotation.AnnotationTarget.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/annotationsOnUseSiteTargets.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/annotationsOnUseSiteTargets.fir.kt index 5605a746d7e..9221bd6262a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/annotationsOnUseSiteTargets.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/annotationsOnUseSiteTargets.fir.kt @@ -8,6 +8,6 @@ interface Test { @get:Synchronized val c: Int - @get:JvmOverloads + @get:JvmOverloads val d: Int } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/jvmName.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/jvmName.fir.kt index 2549e6fa027..1319ffd3d8a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/jvmName.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationApplicability/jvmName.fir.kt @@ -6,10 +6,10 @@ fun foo() {} @JvmName("b") fun Any.foo() {} -@JvmName("c") +@JvmName("c") val px = 1 -@JvmName("d") +@JvmName("d") val Any.px : Int get() = 1 @@ -29,9 +29,9 @@ var vardef: Int = 1 @JvmName("i") set -@JvmName("C") -class C @JvmName("primary") constructor() { - @JvmName("ctr") constructor(x: Int): this() {} +@JvmName("C") +class C @JvmName("primary") constructor() { + @JvmName("ctr") constructor(x: Int): this() {} @JvmName("a") fun foo() {} @@ -39,10 +39,10 @@ class C @JvmName("primary") constructor() { @JvmName("b") fun Any.foo() {} - @JvmName("c") + @JvmName("c") val px = 1 - @JvmName("d") + @JvmName("d") val Any.px : Int get() = 1 @@ -61,7 +61,7 @@ fun foo1() { @JvmName("a") fun foo() {} - @JvmName("a") + @JvmName("a") val x = 1 } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.fir.kt index 37c5c87499d..67fd7c1f82d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.fir.kt @@ -4,6 +4,6 @@ class A @Metadata(extraString = "_") annotation class B(val m: Metadata) -@Metadata(extraInt = 0) +@Metadata(extraInt = 0) @B(Metadata()) fun f() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.fir.kt index 7ac115521e6..f555bdab2f2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/propertyAccessor.fir.kt @@ -5,10 +5,10 @@ interface B { @JvmDefault val prop1: String - @JvmDefault get() = "" + @JvmDefault get() = "" var prop2: String - @JvmDefault get() = "" - @JvmDefault set(value) {} + @JvmDefault get() = "" + @JvmDefault set(value) {} } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_5.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_5.fir.kt index 4d348041a96..d4b9fa89c19 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_5.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_5.fir.kt @@ -1,27 +1,27 @@ // !LANGUAGE: +NestedClassesInAnnotations +InlineClasses -JvmInlineValueClasses -ProhibitJvmFieldOnOverrideFromInterfaceInPrimaryConstructor // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -@kotlin.jvm.JvmField +@kotlin.jvm.JvmField fun foo() { - @kotlin.jvm.JvmField val x = "A" + @kotlin.jvm.JvmField val x = "A" } annotation class DemoAnnotation -@JvmField +@JvmField abstract class C : I{ - @kotlin.jvm.JvmField constructor(s: String) { + @kotlin.jvm.JvmField constructor(s: String) { } - @kotlin.jvm.JvmField private fun foo(s: String = "OK") { + @kotlin.jvm.JvmField private fun foo(s: String = "OK") { } - @JvmField val a: String by lazy { "A" } + @JvmField val a: String by lazy { "A" } @JvmField open val b: Int = 3 - @JvmField abstract val c: Int + @JvmField abstract val c: Int @JvmField val customGetter: String = "" @@ -49,7 +49,7 @@ abstract class C : I{ field = s } - @JvmField + @JvmField val noBackingField: String get() = "a" @@ -61,8 +61,8 @@ abstract class C : I{ } interface I { - @JvmField val ai: Int - @JvmField val bi: Int + @JvmField val ai: Int + @JvmField val bi: Int get() = 5 } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_6.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_6.fir.kt index 60615c92017..733c97503df 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_6.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/jvmFieldApplicability_1_6.fir.kt @@ -1,27 +1,27 @@ // !LANGUAGE: +NestedClassesInAnnotations +InlineClasses -JvmInlineValueClasses +ProhibitJvmFieldOnOverrideFromInterfaceInPrimaryConstructor // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -@kotlin.jvm.JvmField +@kotlin.jvm.JvmField fun foo() { - @kotlin.jvm.JvmField val x = "A" + @kotlin.jvm.JvmField val x = "A" } annotation class DemoAnnotation -@JvmField +@JvmField abstract class C : I{ - @kotlin.jvm.JvmField constructor(s: String) { + @kotlin.jvm.JvmField constructor(s: String) { } - @kotlin.jvm.JvmField private fun foo(s: String = "OK") { + @kotlin.jvm.JvmField private fun foo(s: String = "OK") { } - @JvmField val a: String by lazy { "A" } + @JvmField val a: String by lazy { "A" } @JvmField open val b: Int = 3 - @JvmField abstract val c: Int + @JvmField abstract val c: Int @JvmField val customGetter: String = "" @@ -49,7 +49,7 @@ abstract class C : I{ field = s } - @JvmField + @JvmField val noBackingField: String get() = "a" @@ -61,8 +61,8 @@ abstract class C : I{ } interface I { - @JvmField val ai: Int - @JvmField val bi: Int + @JvmField val ai: Int + @JvmField val bi: Int get() = 5 } diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.fir.kt deleted file mode 100644 index 1a3bde84266..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.fir.kt +++ /dev/null @@ -1,8 +0,0 @@ -class A { - @JvmStatic constructor() {} - inner class B { - @JvmStatic constructor() {} - } -} - -class C @JvmStatic constructor() \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.kt index 0934bce2178..dee1b7fac40 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmStatic/constructors.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL class A { @JvmStatic constructor() {} inner class B { diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.fir.kt index d6af5620c67..be12854d0f1 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.fir.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_TYPEALIAS_PARAMETER // !LANGUAGE: -TrailingCommas -@Target(AnnotationTarget.TYPE) +@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER) annotation class Anno class Foo1 diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt index af5920cbc94..9e69ea90cb2 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.kt @@ -1,7 +1,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_TYPEALIAS_PARAMETER // !LANGUAGE: -TrailingCommas -@Target(AnnotationTarget.TYPE) +@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER) annotation class Anno class Foo1,> diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt index 7814fadbf1e..fb9412aff8e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithDisabledFeature.txt @@ -19,7 +19,7 @@ public interface A1 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public final annotation class Anno : kotlin.Annotation { public constructor Anno() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt index 52152e81816..04410ddcb2f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.kt @@ -2,7 +2,7 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_TYPEALIAS_PARAMETER // !LANGUAGE: +TrailingCommas -@Target(AnnotationTarget.TYPE) +@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER) annotation class Anno class Foo1 diff --git a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt index d531e7f7b5c..83d389d8fb6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/trailingComma/typeParametersWithEnabledFeature.txt @@ -20,7 +20,7 @@ public interface A1 { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE}) public final annotation class Anno : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.TYPE_PARAMETER}) public final annotation class Anno : kotlin.Annotation { public constructor Anno() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt index bf0eed1b61d..1ca554dfd0c 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -620,6 +620,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert token, ) } + add(FirErrors.WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET) { firDiagnostic -> + WrongAnnotationTargetWithUseSiteTargetImpl( + firDiagnostic.a, + firDiagnostic.b, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } add(FirErrors.EXPOSED_TYPEALIAS_EXPANDED_TYPE) { firDiagnostic -> ExposedTypealiasExpandedTypeImpl( firDiagnostic.a, diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt index 6ccce2a267c..496b7df27f5 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -443,6 +443,12 @@ sealed class KtFirDiagnostic : KtDiagnosticWithPsi { abstract val actualTarget: String } + abstract class WrongAnnotationTargetWithUseSiteTarget : KtFirDiagnostic() { + override val diagnosticClass get() = WrongAnnotationTargetWithUseSiteTarget::class + abstract val actualTarget: String + abstract val useSiteTarget: String + } + abstract class ExposedTypealiasExpandedType : KtFirDiagnostic() { override val diagnosticClass get() = ExposedTypealiasExpandedType::class abstract val elementVisibility: EffectiveVisibility diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt index f73ee85dca3..efeda36cc2e 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -720,6 +720,15 @@ internal class WrongAnnotationTargetImpl( override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) } +internal class WrongAnnotationTargetWithUseSiteTargetImpl( + override val actualTarget: String, + override val useSiteTarget: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.WrongAnnotationTargetWithUseSiteTarget(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) +} + internal class ExposedTypealiasExpandedTypeImpl( override val elementVisibility: EffectiveVisibility, override val restrictingDeclaration: KtSymbol,