Introduce EXPERIMENTAL_ANNOTATION_WITH_WRONG_RETENTION diagnostic

#KT-22941 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-05-19 14:52:53 +03:00
committed by teamcityserver
parent 7393465696
commit d8d38862d9
77 changed files with 169 additions and 50 deletions
@@ -207,9 +207,11 @@ fun Annotated.isDocumentedAnnotation(): Boolean =
annotations.findAnnotation(StandardNames.FqNames.mustBeDocumented) != null
fun Annotated.getAnnotationRetention(): KotlinRetention? {
val retentionArgumentValue =
annotations.findAnnotation(StandardNames.FqNames.retention)?.allValueArguments?.get(RETENTION_PARAMETER_NAME)
as? EnumValue ?: return null
return annotations.findAnnotation(StandardNames.FqNames.retention)?.getAnnotationRetention()
}
fun AnnotationDescriptor.getAnnotationRetention(): KotlinRetention? {
val retentionArgumentValue = allValueArguments[RETENTION_PARAMETER_NAME] as? EnumValue ?: return null
val retentionArgumentValueName = retentionArgumentValue.enumEntryName.asString()
return KotlinRetention.values().firstOrNull { it.name == retentionArgumentValueName }