Introduce declaration checker for DeprecatedSinceKotlin annotation

- DeprecatedSinceKotlin annotation should only be applicable when
   there's `@Deprecated` annotation on the same declaration
 - Deprecation level shouldn't be specified in the relevant
   `@Deprecated` annotation
 - Check that warningSince <= errorSince <= hiddenSince
This commit is contained in:
Mikhail Zarechenskiy
2020-06-17 15:52:57 +03:00
parent 0aaf29c045
commit 60c51476f2
12 changed files with 199 additions and 8 deletions
@@ -0,0 +1,42 @@
@Deprecated("", ReplaceWith(""))
@DeprecatedSinceKotlin("", warningSince = "1.0", errorSince = "1.1", hiddenSince = "1.2")
fun good() {}
@DeprecatedSinceKotlin("")
class Clazz
@Deprecated("", level = DeprecationLevel.WARNING)
@DeprecatedSinceKotlin("")
fun fooWarning() {}
@Deprecated("", ReplaceWith(""), DeprecationLevel.WARNING)
@DeprecatedSinceKotlin("")
fun fooDefaultWarning() {}
@Deprecated("", level = DeprecationLevel.ERROR)
@DeprecatedSinceKotlin("")
fun fooError() {}
@Deprecated("", level = DeprecationLevel.HIDDEN)
@DeprecatedSinceKotlin("")
fun fooHidden() {}
@Deprecated("")
@DeprecatedSinceKotlin("", warningSince = "1.1", errorSince = "1.0")
fun fooWarningIsGreater1() {}
@Deprecated("")
@DeprecatedSinceKotlin("", warningSince = "1.1", hiddenSince = "1.0")
fun fooWarningIsGreater2() {}
@Deprecated("")
@DeprecatedSinceKotlin("", warningSince = "1.1", errorSince = "1.3", hiddenSince = "1.2")
fun fooErrorIsGreater() {}
@Deprecated("")
@DeprecatedSinceKotlin("", ReplaceWith(""), "1.2", "1.1", "1.1")
fun fooDefault() {}
@Deprecated("")
@DeprecatedSinceKotlin("", ReplaceWith(""), "1.1", "1.1", "1.1")
fun fooEqual() {}
@@ -0,0 +1,42 @@
@Deprecated("", ReplaceWith(""))
@DeprecatedSinceKotlin("", warningSince = "1.0", errorSince = "1.1", hiddenSince = "1.2")
fun good() {}
@<!DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED!>DeprecatedSinceKotlin<!>("")
class Clazz
@Deprecated("", level = DeprecationLevel.WARNING)
@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>("")
fun fooWarning() {}
@Deprecated("", ReplaceWith(""), DeprecationLevel.WARNING)
@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>("")
fun fooDefaultWarning() {}
@Deprecated("", level = DeprecationLevel.ERROR)
@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>("")
fun fooError() {}
@Deprecated("", level = DeprecationLevel.HIDDEN)
@<!DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL!>DeprecatedSinceKotlin<!>("")
fun fooHidden() {}
@Deprecated("")
@<!DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS!>DeprecatedSinceKotlin<!>("", warningSince = "1.1", errorSince = "1.0")
fun fooWarningIsGreater1() {}
@Deprecated("")
@<!DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS!>DeprecatedSinceKotlin<!>("", warningSince = "1.1", hiddenSince = "1.0")
fun fooWarningIsGreater2() {}
@Deprecated("")
@<!DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS!>DeprecatedSinceKotlin<!>("", warningSince = "1.1", errorSince = "1.3", hiddenSince = "1.2")
fun fooErrorIsGreater() {}
@Deprecated("")
@<!DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS!>DeprecatedSinceKotlin<!>("", ReplaceWith(""), "1.2", "1.1", "1.1")
fun fooDefault() {}
@Deprecated("")
@DeprecatedSinceKotlin("", ReplaceWith(""), "1.1", "1.1", "1.1")
fun fooEqual() {}
@@ -0,0 +1,19 @@
package
@kotlin.Deprecated(message = "") @kotlin.DeprecatedSinceKotlin(errorSince = "1.1", hiddenSince = "1.1", message = "", replaceWith = kotlin.ReplaceWith(expression = "", imports = {}), warningSince = "1.2") public fun fooDefault(): kotlin.Unit
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "", replaceWith = kotlin.ReplaceWith(expression = "", imports = {})) @kotlin.DeprecatedSinceKotlin(message = "") public fun fooDefaultWarning(): kotlin.Unit
@kotlin.Deprecated(message = "") @kotlin.DeprecatedSinceKotlin(errorSince = "1.1", hiddenSince = "1.1", message = "", replaceWith = kotlin.ReplaceWith(expression = "", imports = {}), warningSince = "1.1") public fun fooEqual(): kotlin.Unit
@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") @kotlin.DeprecatedSinceKotlin(message = "") public fun fooError(): kotlin.Unit
@kotlin.Deprecated(message = "") @kotlin.DeprecatedSinceKotlin(errorSince = "1.3", hiddenSince = "1.2", message = "", warningSince = "1.1") public fun fooErrorIsGreater(): kotlin.Unit
@kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "") @kotlin.DeprecatedSinceKotlin(message = "") public fun fooHidden(): kotlin.Unit
@kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "") @kotlin.DeprecatedSinceKotlin(message = "") public fun fooWarning(): kotlin.Unit
@kotlin.Deprecated(message = "") @kotlin.DeprecatedSinceKotlin(errorSince = "1.0", message = "", warningSince = "1.1") public fun fooWarningIsGreater1(): kotlin.Unit
@kotlin.Deprecated(message = "") @kotlin.DeprecatedSinceKotlin(hiddenSince = "1.0", message = "", warningSince = "1.1") public fun fooWarningIsGreater2(): kotlin.Unit
@kotlin.Deprecated(message = "", replaceWith = kotlin.ReplaceWith(expression = "", imports = {})) @kotlin.DeprecatedSinceKotlin(errorSince = "1.1", hiddenSince = "1.2", message = "", warningSince = "1.0") public fun good(): kotlin.Unit
@kotlin.DeprecatedSinceKotlin(message = "") public final class Clazz {
public constructor Clazz()
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
}