Add stdlib-gen DSL support for DeprecatedSinceKotlin annotation

This commit is contained in:
Ilya Gorbunov
2020-07-16 05:53:11 +03:00
parent 5eb0242941
commit a9f4479557
2 changed files with 12 additions and 2 deletions
@@ -136,7 +136,9 @@ enum class SequenceClass {
stateful
}
data class Deprecation(val message: String, val replaceWith: String? = null, val level: DeprecationLevel = DeprecationLevel.WARNING)
data class Deprecation(
val message: String, val replaceWith: String? = null, val level: DeprecationLevel = DeprecationLevel.WARNING,
val warningSince: String? = null, val errorSince: String? = null, val hiddenSince: String? = null)
val forBinaryCompatibility = Deprecation("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
data class ThrowsException(val exceptionType: String, val reason: String)
@@ -327,7 +327,15 @@ class MemberBuilder(
deprecated.replaceWith?.let { "ReplaceWith(\"$it\")" },
deprecated.level.let { if (it != DeprecationLevel.WARNING) "level = DeprecationLevel.$it" else null }
)
builder.append("@Deprecated(${args.joinToString(", ")})\n")
builder.appendLine("@Deprecated(${args.joinToString(", ")})")
val versionArgs = listOfNotNull(
deprecated.warningSince?.let { "warningSince = \"$it\"" },
deprecated.errorSince?.let { "errorSince = \"$it\"" },
deprecated.hiddenSince?.let { "hiddenSince = \"$it\"" }
)
if (versionArgs.any()) {
builder.appendLine("@DeprecatedSinceKotlin(${versionArgs.joinToString(", ")})")
}
}
if (!f.isPrimitiveSpecialization && primitive != null) {