diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 8c74e663a87..41a81be3540 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -103,6 +103,7 @@ public interface Errors { DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS = DiagnosticFactory0.create(ERROR); DiagnosticFactory2 API_NOT_AVAILABLE = DiagnosticFactory2.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 46e87809b6b..3142ad54cc6 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -380,6 +380,7 @@ public class DefaultErrorMessages { MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, "DeprecatedSinceKotlin annotation can be used only together with Deprecated annotation"); MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, "DeprecatedSinceKotlin annotation can be used only with unspecified deprecation level of Deprecated annotation"); MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS, "Values of DeprecatedSinceKotlin annotation should be ordered so 'warningSince' <= 'errorSince' <= 'hiddenSince' if specified"); + MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS, "DeprecatedSinceKotlin annotation should have at least one argument"); MAP.put(API_NOT_AVAILABLE, "This declaration is only available since Kotlin {0} and cannot be used with the specified API version {1}", STRING, STRING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedSinceKotlinAnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedSinceKotlinAnnotationChecker.kt index adf7b2e1220..9577839dfb8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedSinceKotlinAnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecatedSinceKotlinAnnotationChecker.kt @@ -48,6 +48,15 @@ object DeprecatedSinceKotlinAnnotationChecker : DeclarationChecker { return } + if (deprecatedSinceAnnotation.allValueArguments.isEmpty()) { + context.trace.report( + Errors.DEPRECATED_SINCE_KOTLIN_WITHOUT_ARGUMENTS.on( + deprecatedSinceAnnotationName + ) + ) + return + } + fun AnnotationDescriptor.getCheckedSinceVersion(name: String) = getSinceVersion(name).also { checkVersion(it, name, context, deprecatedSinceAnnotationName) } diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.fir.kt new file mode 100644 index 00000000000..3364cebaad4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.fir.kt @@ -0,0 +1,7 @@ +@Deprecated("") +@DeprecatedSinceKotlin +fun foo() {} + +fun test() { + foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.kt index 3c42ca900ac..b99ee781fa6 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedSinceKotlin/deprecatedSinceKotlinWithoutArguments.kt @@ -1,7 +1,5 @@ -// FIR_IDENTICAL - @Deprecated("") -@DeprecatedSinceKotlin +@DeprecatedSinceKotlin fun foo() {} fun test() {