Introduce DeprecatedSinceKotlin annotation
This annotation will be used in the standard library to prevent the new compiler from reporting deprecation diagnostics in case an older API version is used (where the declaration was not deprecated yet). #KT-23575 Fixed
This commit is contained in:
committed by
Mikhail Zarechenskiy
parent
b2022144e6
commit
0aaf29c045
@@ -358,22 +358,20 @@ internal fun KtDeclaration.simpleVisibility(): String = when {
|
||||
}
|
||||
|
||||
internal fun KtModifierListOwner.isDeprecated(support: KtUltraLightSupport? = null): Boolean {
|
||||
val jetModifierList = this.modifierList ?: return false
|
||||
if (jetModifierList.annotationEntries.isEmpty()) return false
|
||||
val modifierList = this.modifierList ?: return false
|
||||
if (modifierList.annotationEntries.isEmpty()) return false
|
||||
|
||||
val deprecatedFqName = KotlinBuiltIns.FQ_NAMES.deprecated
|
||||
val deprecatedName = deprecatedFqName.shortName().asString()
|
||||
|
||||
for (annotationEntry in jetModifierList.annotationEntries) {
|
||||
val typeReference = annotationEntry.typeReference ?: continue
|
||||
|
||||
val typeElement = typeReference.typeElement as? KtUserType ?: continue
|
||||
// If it's not a user type, it's definitely not a ref to deprecated
|
||||
for (annotationEntry in modifierList.annotationEntries) {
|
||||
// If it's not a user type, it's definitely not a reference to deprecated
|
||||
val typeElement = annotationEntry.typeReference?.typeElement as? KtUserType ?: continue
|
||||
|
||||
val fqName = toQualifiedName(typeElement) ?: continue
|
||||
|
||||
if (deprecatedFqName == fqName) return true
|
||||
if (deprecatedName == fqName.asString()) return true
|
||||
if (fqName == deprecatedFqName || fqName == KotlinBuiltIns.FQ_NAMES.deprecatedSinceKotlin) return true
|
||||
if (fqName.asString() == deprecatedName) return true
|
||||
}
|
||||
|
||||
return support?.findAnnotation(this, KotlinBuiltIns.FQ_NAMES.deprecated) !== null
|
||||
|
||||
Reference in New Issue
Block a user