diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 5a1838a552d..4e223819622 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -218,9 +218,9 @@ public interface Errors { DiagnosticFactory0 ANNOTATION_CLASS_MEMBER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INVALID_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 NULLABLE_TYPE_OF_ANNOTATION_MEMBER = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_CONST = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR); - DiagnosticFactory0 ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 ANNOTATION_ARGUMENT_MUST_BE_CONST = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE = DiagnosticFactory0.create(WARNING); DiagnosticFactory0 ANNOTATION_USED_AS_ANNOTATION_ARGUMENT = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index d33e1273912..c130542748f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -818,9 +818,9 @@ public class DefaultErrorMessages { MAP.put(ANNOTATION_CLASS_MEMBER, "Members are not allowed in annotation class"); MAP.put(INVALID_TYPE_OF_ANNOTATION_MEMBER, "Invalid type of annotation member"); MAP.put(NULLABLE_TYPE_OF_ANNOTATION_MEMBER, "An annotation parameter cannot be nullable"); - MAP.put(ANNOTATION_PARAMETER_MUST_BE_CONST, "An annotation parameter must be a compile-time constant"); - MAP.put(ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST, "An enum annotation parameter must be a enum constant"); - MAP.put(ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL, "An annotation parameter must be a class literal (T::class)"); + MAP.put(ANNOTATION_ARGUMENT_MUST_BE_CONST, "An annotation argument must be a compile-time constant"); + MAP.put(ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST, "An enum annotation argument must be a enum constant"); + MAP.put(ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL, "An annotation argument must be a class literal (T::class)"); MAP.put(ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT, "Default value of annotation parameter must be a compile-time constant"); MAP.put(ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt index 5cebfae0db2..b1ecfd0ce28 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/constants/evaluate/ConstantExpressionEvaluator.kt @@ -120,9 +120,9 @@ class ConstantExpressionEvaluator( val descriptor = expressionType.constructor.declarationDescriptor val diagnosticFactory = when { - DescriptorUtils.isEnumClass(descriptor) -> Errors.ANNOTATION_PARAMETER_MUST_BE_ENUM_CONST - descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL - else -> Errors.ANNOTATION_PARAMETER_MUST_BE_CONST + DescriptorUtils.isEnumClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST + descriptor is ClassDescriptor && KotlinBuiltIns.isKClass(descriptor) -> Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL + else -> Errors.ANNOTATION_ARGUMENT_MUST_BE_CONST } trace.report(diagnosticFactory.on(argumentExpression)) @@ -156,7 +156,7 @@ class ConstantExpressionEvaluator( if (lhsExpression != null) { val doubleColonLhs = trace.bindingContext.get(BindingContext.DOUBLE_COLON_LHS, lhsExpression) if (doubleColonLhs is DoubleColonLHS.Expression && !doubleColonLhs.isObjectQualifier) { - trace.report(Errors.ANNOTATION_PARAMETER_MUST_BE_KCLASS_LITERAL.on(argumentExpression)) + trace.report(Errors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL.on(argumentExpression)) } } } diff --git a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt index 2343a8f7f40..5de3c6691ba 100644 --- a/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt +++ b/compiler/testData/diagnostics/tests/annotations/MutuallyRecursivelyAnnotatedGlobalFunction.kt @@ -1,4 +1,4 @@ // Functions can be recursively annotated annotation class ann(val x: Int) -@ann(bar()) fun foo() = 1 -@ann(foo()) fun bar() = 2 \ No newline at end of file +@ann(bar()) fun foo() = 1 +@ann(foo()) fun bar() = 2 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.kt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.kt index 89de31c26a3..ee6020f9fe6 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.kt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedFunctionParameter.kt @@ -1,3 +1,3 @@ // Function parameter CAN be recursively annotated annotation class ann(val x: Int) -fun foo(@ann(foo(1)) x: Int): Int = x \ No newline at end of file +fun foo(@ann(foo(1)) x: Int): Int = x \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.kt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.kt index b486f2855b4..2bac172e2b9 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.kt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedGlobalFunction.kt @@ -1,3 +1,3 @@ // Functions can be recursively annotated annotation class ann(val x: Int) -@ann(foo()) fun foo() = 1 \ No newline at end of file +@ann(foo()) fun foo() = 1 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.kt b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.kt index 603d997b238..beb12e52cc1 100644 --- a/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.kt +++ b/compiler/testData/diagnostics/tests/annotations/RecursivelyAnnotatedProperty.kt @@ -1,5 +1,5 @@ // Properties can be recursively annotated annotation class ann(val x: Int) class My { - @ann(x) val x: Int = 1 + @ann(x) val x: Int = 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt index cd939098784..d3e55b46283 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/booleanLocalVal.kt @@ -2,5 +2,5 @@ annotation class Ann(vararg val i: Boolean) fun foo() { val bool1 = true - @Ann(bool1) val a = bool1 + @Ann(bool1) val a = bool1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt index dac0379704d..69999eb86f0 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/compareAndEquals.kt @@ -7,10 +7,10 @@ fun foo() { val a4 = a1 > a2 @Ann( - a1, - a2, - a3, - a1 > a2, - a1 == a2 + a1, + a2, + a3, + a1 > a2, + a1 == a2 ) val b = 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.kt index b85caeb8249..0a56d7740c0 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/enumConst.kt @@ -1,6 +1,6 @@ annotation class AnnE(val i: MyEnum) -@AnnE(e) +@AnnE(e) class Test val e: MyEnum = MyEnum.A diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.kt index f19072ac99b..bf4955bbbd3 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/javaProperties.kt @@ -14,12 +14,12 @@ public class Test { annotation class Ann(vararg val i: Int) @Ann( - Test.i1, + Test.i1, Test.i2, - Test.i3, + Test.i3, Test.i4, - Test.i5, - Test.i6, - Test().i7 + Test.i5, + Test.i6, + Test().i7 ) class A diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt index f1e30662de0..4597228b1f9 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/kotlinProperties.kt @@ -1,12 +1,12 @@ annotation class Ann(vararg val i: Int) @Ann( - i1, + i1, i2, - i3, + i3, i4, - i5, - i6 + i5, + i6 ) class Test diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/standaloneInExpression.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/standaloneInExpression.kt index dcec148fbe6..abb407b4f6c 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/standaloneInExpression.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/standaloneInExpression.kt @@ -4,15 +4,15 @@ enum class MyEnum { A } -@AnnE("1" + MyEnum.A) +@AnnE("1" + MyEnum.A) class Test -@AnnE("1" + MyEnum::class) +@AnnE("1" + MyEnum::class) class Test2 -@AnnE("1" + AnnE("23")) +@AnnE("1" + AnnE("23")) class Test3 -@AnnE("1" + arrayOf("23", "34")) +@AnnE("1" + arrayOf("23", "34")) class Test4 diff --git a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt index f9e3e0161eb..1a8e9a41743 100644 --- a/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt +++ b/compiler/testData/diagnostics/tests/annotations/annotationParameterMustBeConstant/strings.kt @@ -12,17 +12,17 @@ fun foo() { val a5 = 1.0 @Ann( - a1, - a2, - a3, + a1, + a2, + a3, "$topLevel", - "$a1", - "$a1 $topLevel", - "$a4", - "$a5", - a1 + a2, - "a" + a2, + "$a1", + "$a1 $topLevel", + "$a4", + "$a5", + a1 + a2, + "a" + a2, "a" + topLevel, - "a" + a4 + "a" + a4 ) val b = 1 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt b/compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt index cab2cbcc224..c78bfd8c943 100644 --- a/compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt +++ b/compiler/testData/diagnostics/tests/classLiteral/inAnnotationArguments.kt @@ -13,7 +13,7 @@ class C { fun foo() = "foo" -@Ann("foo"::class) +@Ann("foo"::class) fun test1() {} @Ann(String::class) @@ -28,8 +28,8 @@ fun test5() {} @Ann(C.Companion::class) fun test6() {} -@Ann(foo()::class) +@Ann(foo()::class) fun test7() {} -@AnnArray(arrayOf(""::class, String::class, AnObject::class)) +@AnnArray(arrayOf(""::class, String::class, AnObject::class)) fun test8() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.kt b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.kt index 012128a1de3..389f455614c 100644 --- a/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.kt +++ b/compiler/testData/diagnostics/tests/collectionLiterals/collectionLiteralsWithVarargs.kt @@ -17,7 +17,7 @@ fun test1_0() {} @Ann1(*["a", "b"]) fun test1_1() {} -@Ann1(*["a", 1, null]) +@Ann1(*["a", 1, null]) fun test1_2() {} @Ann2(*[]) diff --git a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.kt b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.kt index 759b11b59c0..63c018a72c0 100644 --- a/compiler/testData/diagnostics/tests/evaluate/divisionByZero.kt +++ b/compiler/testData/diagnostics/tests/evaluate/divisionByZero.kt @@ -13,6 +13,6 @@ val a8 = 1.div(a2) val a9 = 2 * (1.div(0)) val b1: Byte = 1 / 0 -@Ann(1 / 0) val b2 = 1 +@Ann(1 / 0) val b2 = 1 annotation class Ann(val i : Int) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/modifiers/const/fromJava.kt b/compiler/testData/diagnostics/tests/modifiers/const/fromJava.kt index 0b83d4b182e..412506e511d 100644 --- a/compiler/testData/diagnostics/tests/modifiers/const/fromJava.kt +++ b/compiler/testData/diagnostics/tests/modifiers/const/fromJava.kt @@ -18,9 +18,9 @@ annotation class Ann(val x: Int) @Ann(A.X) fun main1() {} -@Ann(A.Y) +@Ann(A.Y) fun main2() {} val q = A() -@Ann(q.z) +@Ann(q.z) fun main3() {} diff --git a/compiler/testData/diagnostics/tests/scopes/classHeader/annotationOnClass.kt b/compiler/testData/diagnostics/tests/scopes/classHeader/annotationOnClass.kt index 223bc643814..7ddf4a0abec 100644 --- a/compiler/testData/diagnostics/tests/scopes/classHeader/annotationOnClass.kt +++ b/compiler/testData/diagnostics/tests/scopes/classHeader/annotationOnClass.kt @@ -15,13 +15,13 @@ annotation class Ann( ) @Ann( - Nested::class, - Inner::class, - Interface::class, + Nested::class, + Inner::class, + Interface::class, CONST, - Companion.CONST, - Nested.CONST, - Interface.CONST, + Companion.CONST, + Nested.CONST, + Interface.CONST, a, b() ) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt index f7014df99f2..98c74373c3a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/array.kt @@ -2,11 +2,11 @@ @Repeatable annotation class Ann(val i: IntArray) -@Ann(intArrayOf(i)) +@Ann(intArrayOf(i)) @Ann(intArrayOf(i2)) -@Ann(intArrayOf(i3)) -@Ann(intArrayOf(i, i2, i3)) -@Ann(intArrayOf(intArrayOf(i, i2, i3))) +@Ann(intArrayOf(i3)) +@Ann(intArrayOf(i, i2, i3)) +@Ann(intArrayOf(intArrayOf(i, i2, i3))) class Test var i = 1 @@ -19,6 +19,6 @@ fun foo(): Int = 1 @Repeatable annotation class AnnAnn(val i: Array) @AnnAnn(arrayOf(Ann(intArrayOf(1)))) -@AnnAnn(arrayOf(iAnn)) +@AnnAnn(arrayOf(iAnn)) class TestAnn val iAnn = Ann(intArrayOf(1)) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt index 5b2937fffe5..2c0dfd40dcc 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/simple.kt @@ -4,14 +4,14 @@ annotation class Ann(val i: Int) annotation class AnnIA(val ia: IntArray) annotation class AnnSA(val sa: Array) -@Ann(MyClass().i) -@Ann(i) -@Ann(i2) -@AnnIA(ia) -@AnnSA(sa) +@Ann(MyClass().i) +@Ann(i) +@Ann(i2) +@AnnIA(ia) +@AnnSA(sa) class Test { val i = 1 - @Ann(i) val i2 = 1 + @Ann(i) val i2 = 1 } var i = 1 diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt index 661e07cc831..3d3670e3826 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/annotationParameterMustBeConstant/vararg.kt @@ -2,14 +2,14 @@ @Repeatable annotation class Ann(vararg val i: Int) -@Ann(i) +@Ann(i) @Ann(i2) -@Ann(i3) -@Ann(i, i2, i3) -@Ann(*intArrayOf(i)) +@Ann(i3) +@Ann(i, i2, i3) +@Ann(*intArrayOf(i)) @Ann(*intArrayOf(i2)) -@Ann(*intArrayOf(i3)) -@Ann(*intArrayOf(i, i2, i3)) +@Ann(*intArrayOf(i3)) +@Ann(*intArrayOf(i, i2, i3)) class Test var i = 1 @@ -22,6 +22,6 @@ fun foo(): Int = 1 @Repeatable annotation class AnnAnn(vararg val i: Ann) @AnnAnn(*arrayOf(Ann(1))) -@AnnAnn(*arrayOf(iAnn)) +@AnnAnn(*arrayOf(iAnn)) class TestAnn val iAnn = Ann(1) diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt index 0b0c02a3976..bbe61924099 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/kClass/kClassInAnnotation.kt @@ -12,9 +12,9 @@ class A2 @Ann3(arrayOf(A1::class, A2::class)) class MyClass1 -@Ann1(A3::class) +@Ann1(A3::class) class MyClass2 val x = A1::class -@Ann1(x) +@Ann1(x) class MyClass3 diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddAnnotationTargetFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddAnnotationTargetFix.kt index 0c293b9d26e..9b866e44c94 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddAnnotationTargetFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddAnnotationTargetFix.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget import org.jetbrains.kotlin.diagnostics.Diagnostic +import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.jetbrains.kotlin.idea.search.restrictToKotlinSources @@ -65,6 +66,8 @@ class AddAnnotationTargetFix(annotationEntry: KtAnnotationEntry) : KotlinQuickFi } override fun createAction(diagnostic: Diagnostic): KotlinQuickFixAction? { + if (diagnostic.factory != Errors.WRONG_ANNOTATION_TARGET) return null + val entry = diagnostic.psiElement as? KtAnnotationEntry ?: return null val annotationClass = entry.toAnnotationClass() ?: return null if (entry.useSiteTarget != null && entry.getRequiredAnnotationTargets(annotationClass, entry.project).isEmpty()) return null diff --git a/idea/testData/quickfix/moveReceiverAnnotation/notExtensionFun.kt b/idea/testData/quickfix/moveReceiverAnnotation/notExtensionFun.kt index e238bbe2cb9..50556f6cb68 100644 --- a/idea/testData/quickfix/moveReceiverAnnotation/notExtensionFun.kt +++ b/idea/testData/quickfix/moveReceiverAnnotation/notExtensionFun.kt @@ -1,5 +1,5 @@ // "Move annotation to receiver type" "false" -// ERROR: This annotation is not applicable to target 'top level function' and use site target '@receiver' +// ERROR: This annotation is not applicable to target 'declaration' and use site target '@receiver' // ACTION: Make internal // ACTION: Make private diff --git a/idea/testData/quickfix/moveReceiverAnnotation/notExtensionVal.kt b/idea/testData/quickfix/moveReceiverAnnotation/notExtensionVal.kt index 96608ea5cb0..728066bc5ed 100644 --- a/idea/testData/quickfix/moveReceiverAnnotation/notExtensionVal.kt +++ b/idea/testData/quickfix/moveReceiverAnnotation/notExtensionVal.kt @@ -1,5 +1,5 @@ // "Move annotation to receiver type" "false" -// ERROR: This annotation is not applicable to target 'top level property without backing field or delegate' and use site target '@receiver' +// ERROR: This annotation is not applicable to target 'declaration' and use site target '@receiver' // ACTION: Make internal // ACTION: Make private // ACTION: Specify type explicitly diff --git a/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt b/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt index 5b30b6e6e13..1cc36a7920e 100644 --- a/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt +++ b/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt @@ -1,5 +1,5 @@ // "Remove @ from annotation argument" "true" -// ERROR: An annotation parameter must be a compile-time constant +// ERROR: An annotation argument must be a compile-time constant annotation class Y() annotation class X(val value: Y, val y: Y) diff --git a/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after b/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after index 444d0644e54..3fc593c6305 100644 --- a/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after +++ b/idea/testData/quickfix/removeAtFromAnnotationArgument/namedParam.kt.after @@ -1,5 +1,5 @@ // "Remove @ from annotation argument" "true" -// ERROR: An annotation parameter must be a compile-time constant +// ERROR: An annotation argument must be a compile-time constant annotation class Y() annotation class X(val value: Y, val y: Y) diff --git a/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt b/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt index c7951fb10c7..2b7d0c165b2 100644 --- a/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt +++ b/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt @@ -1,5 +1,5 @@ // "Remove @ from annotation argument" "true" -// ERROR: An annotation parameter must be a compile-time constant +// ERROR: An annotation argument must be a compile-time constant annotation class Y() annotation class X(val value: Y) diff --git a/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after b/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after index ee5b0b9f366..43a4a423d99 100644 --- a/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after +++ b/idea/testData/quickfix/removeAtFromAnnotationArgument/simple.kt.after @@ -1,5 +1,5 @@ // "Remove @ from annotation argument" "true" -// ERROR: An annotation parameter must be a compile-time constant +// ERROR: An annotation argument must be a compile-time constant annotation class Y() annotation class X(val value: Y) diff --git a/jps-plugin/testData/incremental/pureKotlin/fileWithConstantRemoved/build.log b/jps-plugin/testData/incremental/pureKotlin/fileWithConstantRemoved/build.log index 841acd22cd2..fbb3ceecee7 100644 --- a/jps-plugin/testData/incremental/pureKotlin/fileWithConstantRemoved/build.log +++ b/jps-plugin/testData/incremental/pureKotlin/fileWithConstantRemoved/build.log @@ -21,4 +21,4 @@ Exit code: ABORT ------------------------------------------ COMPILATION FAILED Unresolved reference: test -An annotation parameter must be a compile-time constant +An annotation argument must be a compile-time constant diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt index ba36685d1aa..8ef0ab2e08d 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/errorLocationMapping.kt @@ -10,7 +10,7 @@ // EXPECTED_ERROR(kotlin:32:5) cannot find symbol // EXPECTED_ERROR(kotlin:35:5) cannot find symbol -@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION") +@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION") import kotlin.reflect.KClass @Anno(ABC::class) diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt index 354dbb0791e..beed6b639ca 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.kt @@ -3,7 +3,7 @@ // NO_VALIDATION // WITH_RUNTIME -@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE") +@file:Suppress("UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE") import java.util.Calendar import kotlin.reflect.KClass diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.txt b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.txt index ba9e50d965e..47115b22c55 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.txt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/nonExistentClassTypesConversion.txt @@ -34,7 +34,7 @@ public final class MyType { import java.util.Calendar; import kotlin.reflect.KClass; -@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE", "ANNOTATION_PARAMETER_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE"}) +@kotlin.Suppress(names = {"UNRESOLVED_REFERENCE", "ANNOTATION_ARGUMENT_MUST_BE_CONST", "NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION", "UNSUPPORTED_FEATURE"}) @kotlin.Metadata() public final class NonExistentClassTypesConversionKt { }