diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 1f4fbb6a73b..563630ad157 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -229,6 +229,9 @@ public interface Errors { DiagnosticFactory0 ANNOTATION_USED_AS_ANNOTATION_ARGUMENT = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 ANNOTATION_ARGUMENT_IS_NON_CONST = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 LOCAL_ANNOTATION_CLASS = DiagnosticFactory0.create(WARNING); DiagnosticFactory0 LOCAL_ANNOTATION_CLASS_ERROR = 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 dad2664112f..0f6b0a7b265 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -840,6 +840,11 @@ public class DefaultErrorMessages { MAP.put(ANNOTATION_USED_AS_ANNOTATION_ARGUMENT, "An annotation can't be used as the annotations argument"); MAP.put(ANNOTATION_ARGUMENT_IS_NON_CONST, "An annotation argument must be a compile-time constant"); + MAP.put(RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION, + "Expression annotations with retention other than SOURCE are prohibited"); + MAP.put(RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING, + "Expression annotations with retention other than SOURCE are deprecated"); + MAP.put(LOCAL_ANNOTATION_CLASS, "Local annotation classes are deprecated and will be unsupported in a future release"); MAP.put(LOCAL_ANNOTATION_CLASS_ERROR, "Annotation class cannot be local"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt index 00a61c47b97..18fe50aa4c0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TargetPlatform.kt @@ -118,7 +118,8 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( KClassWithIncorrectTypeArgumentChecker, SuspendOperatorsCheckers, InlineClassDeclarationChecker, - PropertiesWithBackingFieldsInsideInlineClass() + PropertiesWithBackingFieldsInsideInlineClass(), + AnnotationClassTargetAndRetentionChecker() ) private val DEFAULT_CALL_CHECKERS = listOf( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/AnnotationClassTargetAndRetentionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/AnnotationClassTargetAndRetentionChecker.kt new file mode 100644 index 00000000000..c5d9031e4f1 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/AnnotationClassTargetAndRetentionChecker.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.kotlin.descriptors.annotations.KotlinRetention +import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.resolve.AnnotationChecker +import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils +import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.descriptorUtil.getAnnotationRetention + +class AnnotationClassTargetAndRetentionChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + if (descriptor !is ClassDescriptor) return + if (declaration !is KtClassOrObject) return + if (!DescriptorUtils.isAnnotationClass(descriptor)) return + + val targets = AnnotationChecker.applicableTargetSet(descriptor) ?: return + val retention = descriptor.getAnnotationRetention() ?: KotlinRetention.RUNTIME + + if (targets.contains(KotlinTarget.EXPRESSION) && retention != KotlinRetention.SOURCE) { + val retentionAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.retention) + val targetAnnotation = descriptor.annotations.findAnnotation(KotlinBuiltIns.FQ_NAMES.target) + + val diagnostics = + if (context.languageVersionSettings.supportsFeature(LanguageFeature.RestrictRetentionForExpressionAnnotations)) + Errors.RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION + else + Errors.RESTRICTED_RETENTION_FOR_EXPRESSION_ANNOTATION_WARNING + context.trace.report(diagnostics.on(retentionAnnotation?.psi ?: targetAnnotation?.psi ?: declaration)) + } + } + + private val AnnotationDescriptor.psi: PsiElement? + get() = DescriptorToSourceUtils.getSourceFromAnnotation(this) +} \ No newline at end of file diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/library-1/Ann.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/library-1/Ann.kt index cca8ef7e89f..985e7eb899d 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/library-1/Ann.kt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/library-1/Ann.kt @@ -2,5 +2,5 @@ package test import kotlin.annotation.AnnotationTarget.* -@Target(CLASS, ANNOTATION_CLASS, TYPE_PARAMETER, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, EXPRESSION, FILE) +@Target(CLASS, ANNOTATION_CLASS, TYPE_PARAMETER, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, FILE) annotation class Ann(val s: String) diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/usage/usage.kt b/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/usage/usage.kt index 22b35e03ce5..e452f5e042c 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/usage/usage.kt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/replaceAnnotationClassWithInterface/usage/usage.kt @@ -3,5 +3,5 @@ package test @Ann("class") class Test { @Ann("function") - fun foo(@Ann("parameter") s: @Ann("parameter type") String): @Ann("return type") String = @Ann("expression") s + fun foo(@Ann("parameter") s: @Ann("parameter type") String): @Ann("return type") String = s } diff --git a/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.kt b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.kt new file mode 100644 index 00000000000..d978f5d96f8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +RestrictRetentionForExpressionAnnotations + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class TestRetentionSource + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.BINARY) +annotation class TestRetentionBinary + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.RUNTIME) +annotation class TestRetentionRuntime \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.txt b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.txt new file mode 100644 index 00000000000..39ce6cd4d2d --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.txt @@ -0,0 +1,22 @@ +package + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class TestRetentionBinary : kotlin.Annotation { + public constructor TestRetentionBinary() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class TestRetentionRuntime : kotlin.Annotation { + public constructor TestRetentionRuntime() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class TestRetentionSource : kotlin.Annotation { + public constructor TestRetentionSource() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.kt b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.kt new file mode 100644 index 00000000000..ccd411a296f --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: -RestrictRetentionForExpressionAnnotations + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class TestRetentionSource + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.BINARY) +annotation class TestRetentionBinary + +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.RUNTIME) +annotation class TestRetentionRuntime \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.txt b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.txt new file mode 100644 index 00000000000..39ce6cd4d2d --- /dev/null +++ b/compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.txt @@ -0,0 +1,22 @@ +package + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class TestRetentionBinary : kotlin.Annotation { + public constructor TestRetentionBinary() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class TestRetentionRuntime : kotlin.Annotation { + public constructor TestRetentionRuntime() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class TestRetentionSource : kotlin.Annotation { + public constructor TestRetentionSource() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.kt b/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.kt index 2120ea95cdd..c1884e0f9aa 100644 --- a/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.kt +++ b/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.kt @@ -1,8 +1,11 @@ // !DIAGNOSTICS: -UNUSED_PARAMETER @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class Ann1 + @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class Ann2(val x: String) fun bar() {} diff --git a/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.txt b/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.txt index 9e652f5f82e..d505f093a5b 100644 --- a/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.txt +++ b/compiler/testData/diagnostics/tests/annotations/blockLevelOnTheSameLineWarning.txt @@ -5,14 +5,14 @@ public fun bar(/*0*/ block: () -> kotlin.Unit): kotlin.Unit public fun foo(/*0*/ y: kotlin.IntArray): kotlin.Unit public infix fun kotlin.Int.foo(/*0*/ other: kotlin.Int): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class Ann1 : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Ann1 : kotlin.Annotation { public constructor Ann1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class Ann2 : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Ann2 : kotlin.Annotation { public constructor Ann2(/*0*/ x: kotlin.String) public final val x: kotlin.String public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt index 8bfc6a58b9b..74d7ad2cb64 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.kt @@ -1,5 +1,6 @@ // !WITH_NEW_INFERENCE @Target(AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class test fun foo(@test f : Int) {} diff --git a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt index 95d9546982d..c6a03499401 100644 --- a/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt +++ b/compiler/testData/diagnostics/tests/annotations/kt1860-positive.txt @@ -11,7 +11,7 @@ public final class Hello { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION}) public final annotation class test : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class test : kotlin.Annotation { public constructor test() 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/tests/annotations/onExpression.kt b/compiler/testData/diagnostics/tests/annotations/onExpression.kt index f5c1abdd2d5..9ffd58eb14a 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.kt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.kt @@ -1,4 +1,5 @@ fun foo() = @ann 1 @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class ann \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/onExpression.txt b/compiler/testData/diagnostics/tests/annotations/onExpression.txt index cdec0d920e9..6dff685f347 100644 --- a/compiler/testData/diagnostics/tests/annotations/onExpression.txt +++ b/compiler/testData/diagnostics/tests/annotations/onExpression.txt @@ -2,7 +2,7 @@ package public fun foo(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class ann : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class ann : kotlin.Annotation { public constructor ann() 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/tests/annotations/options/assignment.kt b/compiler/testData/diagnostics/tests/annotations/options/assignment.kt index 2d1c469f2c4..733c62f3406 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/assignment.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/assignment.kt @@ -1,4 +1,5 @@ @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class ExprAnn fun foo(): Int { diff --git a/compiler/testData/diagnostics/tests/annotations/options/assignment.txt b/compiler/testData/diagnostics/tests/annotations/options/assignment.txt index 3cf8fa06393..fcad9e2dee3 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/assignment.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/assignment.txt @@ -2,7 +2,7 @@ package public fun foo(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class ExprAnn : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class ExprAnn : kotlin.Annotation { public constructor ExprAnn() 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/tests/annotations/options/functionExpression.kt b/compiler/testData/diagnostics/tests/annotations/options/functionExpression.kt index 4ecf25e4ffb..7bd5906366e 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/functionExpression.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/functionExpression.kt @@ -1,4 +1,5 @@ @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class ExprAnn @Target(AnnotationTarget.FUNCTION) diff --git a/compiler/testData/diagnostics/tests/annotations/options/functionExpression.txt b/compiler/testData/diagnostics/tests/annotations/options/functionExpression.txt index e3a7f0b8b29..702a1f745a3 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/functionExpression.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/functionExpression.txt @@ -2,7 +2,7 @@ package public fun foo(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class ExprAnn : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class ExprAnn : kotlin.Annotation { public constructor ExprAnn() 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/tests/annotations/options/functions.kt b/compiler/testData/diagnostics/tests/annotations/options/functions.kt index 902aca5dde4..a80f28b9469 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/functions.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/functions.kt @@ -7,6 +7,7 @@ annotation class FunAnn annotation class SourceAnn @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class ExprAnn fun bar(arg: () -> Int) = arg() diff --git a/compiler/testData/diagnostics/tests/annotations/options/functions.txt b/compiler/testData/diagnostics/tests/annotations/options/functions.txt index 416e0743af5..d46da7bad4f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/functions.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/functions.txt @@ -6,7 +6,7 @@ public inline fun fast2(/*0*/ x: kotlin.Int, /*1*/ arg: () -> kotlin.Int): kotli public fun foo(/*0*/ arg: kotlin.Int): kotlin.Unit @FunAnn public fun gav(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class ExprAnn : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class ExprAnn : kotlin.Annotation { public constructor ExprAnn() 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/tests/annotations/options/prefix.kt b/compiler/testData/diagnostics/tests/annotations/options/prefix.kt index d96f4ca8faf..1b77ce9d700 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/prefix.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/prefix.kt @@ -2,6 +2,7 @@ annotation class FunAnn @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class ExprAnn fun foo(): Int { diff --git a/compiler/testData/diagnostics/tests/annotations/options/prefix.txt b/compiler/testData/diagnostics/tests/annotations/options/prefix.txt index e3a7f0b8b29..702a1f745a3 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/prefix.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/prefix.txt @@ -2,7 +2,7 @@ package public fun foo(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class ExprAnn : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class ExprAnn : kotlin.Annotation { public constructor ExprAnn() 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/tests/annotations/options/repeatable.kt b/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt index b6e95dcf20a..cc393f60a39 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/repeatable.kt @@ -14,6 +14,7 @@ annotation class repann2(val f: Boolean) annotation class binrepann @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) @Repeatable annotation class repexpr @@ -26,5 +27,5 @@ annotation class repexpr @binrepann @binrepann class BinaryAnnotated @repann @repann fun foo(@repann @repann x: Int): Int { - @repexpr @repexpr return x + @repexpr @repexpr return x } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt index b938243507e..225e401362a 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/repeatable.txt @@ -60,7 +60,7 @@ package public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Repeatable public final annotation class repexpr : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) @kotlin.annotation.Repeatable public final annotation class repexpr : kotlin.Annotation { public constructor repexpr() 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/tests/annotations/options/targets/expr.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt index 12332e94465..b3ef2d033db 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.kt @@ -1,6 +1,8 @@ annotation class base -@Target(AnnotationTarget.EXPRESSION) annotation class special +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class special fun transform(i: Int, tr: (Int) -> Int): Int = @base @special tr(@special i) diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt index a0f9a6e59ca..767975123db 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/expr.txt @@ -10,7 +10,7 @@ public final annotation class base : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class special : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class special : kotlin.Annotation { public constructor special() 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/tests/annotations/options/targets/funtypeargs.kt b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt index bf63064be24..89ffc53ed7f 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.kt @@ -1,4 +1,5 @@ @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class special @Target(AnnotationTarget.TYPE) diff --git a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt index d0fbdee071a..ebcea355903 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/targets/funtypeargs.txt @@ -10,7 +10,7 @@ public fun transform(/*0*/ i: kotlin.Int, /*1*/ tr: (@special kotlin.Int) -> kot public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class special : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class special : kotlin.Annotation { public constructor special() 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/tests/annotations/options/unrepeatable.kt b/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.kt index 9ba2e58edc7..b43d1cb91f4 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.kt +++ b/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.kt @@ -6,7 +6,9 @@ annotation class ann(val y: Int) @ann(3) @ann(7) @ann(42) class TripleAnnotated -@Target(AnnotationTarget.EXPRESSION) annotation class annexpr +@Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) +annotation class annexpr @ann(0) @ann(1) fun foo(@ann(7) @ann(2) x: Int): Int { @annexpr @annexpr return x diff --git a/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.txt b/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.txt index 43fcf6c2be0..e3f05e5af04 100644 --- a/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.txt +++ b/compiler/testData/diagnostics/tests/annotations/options/unrepeatable.txt @@ -26,7 +26,7 @@ public final annotation class ann : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class annexpr : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class annexpr : kotlin.Annotation { public constructor annexpr() 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/tests/deparenthesize/annotatedSafeCall.kt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt index d06fa5d2a08..f5ccb9a914f 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.kt @@ -1,4 +1,5 @@ @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class foo fun f(s : String?) : Boolean { diff --git a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt index dcc675b56d4..a216a7a24cb 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt +++ b/compiler/testData/diagnostics/tests/deparenthesize/annotatedSafeCall.txt @@ -2,7 +2,7 @@ package public fun f(/*0*/ s: kotlin.String?): kotlin.Boolean -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class foo : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class foo : kotlin.Annotation { public constructor foo() 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/tests/inference/expectedTypeFromCastParenthesized.kt b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt index fe50339913c..0bdaa750a1c 100644 --- a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt @@ -1,6 +1,7 @@ // !LANGUAGE: +ExpectedTypeFromCast @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class bar fun foo(): T = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt index 9965fa808ce..ce7b443c003 100644 --- a/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt +++ b/compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt @@ -16,7 +16,7 @@ public object X { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class bar : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class bar : kotlin.Annotation { public constructor bar() 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/tests/smartCasts/lambdaCallAnnotated.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.kt index 3a5e07d8cb2..f8ec7b27ceb 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.kt @@ -1,6 +1,7 @@ // See KT-9134: smart cast is not provided inside lambda call @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class My fun bar(): Int = @My { diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.txt index c71ad6cd9bf..6e8e37e4ae0 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.txt +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaCallAnnotated.txt @@ -2,7 +2,7 @@ package public fun bar(): kotlin.Int -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class My : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class My : kotlin.Annotation { public constructor My() 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/testsWithJsStdLibAndBackendCompilation/unsupportedFeatures/annotations.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/unsupportedFeatures/annotations.kt index 4ead5ca0c2a..57ac900a942 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/unsupportedFeatures/annotations.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/unsupportedFeatures/annotations.kt @@ -6,11 +6,11 @@ package foo @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) annotation class AnnotationWithSourceRetention -@Retention(AnnotationRetention.BINARY) +@Retention(AnnotationRetention.BINARY) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) annotation class AnnotationWithBinaryRetention -@Retention(AnnotationRetention.RUNTIME) +@Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) annotation class AnnotationWithRuntimeRetention diff --git a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.txt b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.txt index 14c48063f67..c5f16ac6a28 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/annotations/jvmField/interface13.txt @@ -87,3 +87,17 @@ public interface F { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } } + +public interface F { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion { + private constructor Companion() + @kotlin.jvm.JvmField public open val a: kotlin.Int = 3 + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspend.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspend.kt index 951ceb0a606..48689a0de6a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspend.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspend.kt @@ -7,6 +7,7 @@ class A { } @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class Ann fun bar() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspendWithAnyParameter.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspendWithAnyParameter.kt index a6a0c62167d..4ffdaaf5cba 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspendWithAnyParameter.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/modifierFormForNonBuiltInSuspendWithAnyParameter.kt @@ -7,6 +7,7 @@ class A { } @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class Ann fun bar() { diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/nonModifierFormForBuiltIn.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/nonModifierFormForBuiltIn.kt index 29c971fd882..ab5033e663a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/coroutines/nonModifierFormForBuiltIn.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/nonModifierFormForBuiltIn.kt @@ -30,4 +30,5 @@ fun bar() { } @Target(AnnotationTarget.EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class Ann diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt index b71155e3313..8e25491a8bd 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt @@ -16,8 +16,10 @@ annotation class E2 @Experimental(Experimental.Level.WARNING) @Target(EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class E3 @Experimental(Experimental.Level.WARNING) @Target(FILE, EXPRESSION) +@Retention(AnnotationRetention.SOURCE) annotation class E4 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt index 598dc4b7c06..8e584841c67 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt @@ -16,14 +16,14 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class E3 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class E3 : kotlin.Annotation { public constructor E3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE, AnnotationTarget.EXPRESSION}) public final annotation class E4 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE, AnnotationTarget.EXPRESSION}) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class E4 : kotlin.Annotation { public constructor E4() 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/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 5ec350ead6e..99339a67e8f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1068,6 +1068,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.kt"); } + @TestMetadata("RetentionsOfAnnotationWithExpressionTarget_after.kt") + public void testRetentionsOfAnnotationWithExpressionTarget_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.kt"); + } + + @TestMetadata("RetentionsOfAnnotationWithExpressionTarget_before.kt") + public void testRetentionsOfAnnotationWithExpressionTarget_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.kt"); + } + @TestMetadata("typeAnnotations.kt") public void testTypeAnnotations() throws Exception { runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 6a102355c1a..e529f4f794e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1068,6 +1068,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/annotations/RecursivelyIncorrectlyAnnotatedParameter.kt"); } + @TestMetadata("RetentionsOfAnnotationWithExpressionTarget_after.kt") + public void testRetentionsOfAnnotationWithExpressionTarget_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_after.kt"); + } + + @TestMetadata("RetentionsOfAnnotationWithExpressionTarget_before.kt") + public void testRetentionsOfAnnotationWithExpressionTarget_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/annotations/RetentionsOfAnnotationWithExpressionTarget_before.kt"); + } + @TestMetadata("typeAnnotations.kt") public void testTypeAnnotations() throws Exception { runTest("compiler/testData/diagnostics/tests/annotations/typeAnnotations.kt"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index d97d9831582..2da04d84e7d 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -80,6 +80,7 @@ enum class LanguageFeature( ProhibitOperatorMod(KOTLIN_1_3, kind = BUG_FIX), ProhibitAssigningSingleElementsToVarargsInNamedForm(KOTLIN_1_3, kind = BUG_FIX), FunctionTypesWithBigArity(KOTLIN_1_3, sinceApiVersion = ApiVersion.KOTLIN_1_3), + RestrictRetentionForExpressionAnnotations(KOTLIN_1_3, kind = BUG_FIX), StrictJavaNullabilityAssertions(sinceVersion = null, defaultState = State.DISABLED), ProperIeee754Comparisons(sinceVersion = null, defaultState = State.DISABLED, kind = BUG_FIX),