Use deprecation type for some REPEATABLE_* diagnostics
This commit is contained in:
committed by
TeamCityServer
parent
f414a91c66
commit
6fa1c0353c
+19
-22
@@ -103,10 +103,10 @@ class RepeatableAnnotationChecker(
|
||||
)
|
||||
if (nestedClassNamedContainer != null) {
|
||||
trace.report(
|
||||
select(
|
||||
ErrorsJvm.REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER,
|
||||
ErrorsJvm.REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER_ERROR
|
||||
).on(kotlinRepeatable.entry)
|
||||
ErrorsJvm.REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER.on(
|
||||
languageVersionSettings,
|
||||
kotlinRepeatable.entry
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -170,16 +170,14 @@ class RepeatableAnnotationChecker(
|
||||
if (value == null || !KotlinBuiltIns.isArray(value.type) ||
|
||||
value.type.arguments.single().type.constructor.declarationDescriptor != annotationClass
|
||||
) {
|
||||
return select(
|
||||
ErrorsJvm.REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY, ErrorsJvm.REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_ERROR
|
||||
).on(reportOn, containerClass.fqNameSafe, annotationClass.fqNameSafe)
|
||||
return ErrorsJvm.REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY
|
||||
.on(languageVersionSettings, reportOn, containerClass.fqNameSafe, annotationClass.fqNameSafe)
|
||||
}
|
||||
|
||||
val otherNonDefault = containerCtor.valueParameters.find { it.name.asString() != "value" && !it.declaresDefaultValue() }
|
||||
if (otherNonDefault != null) {
|
||||
return select(
|
||||
ErrorsJvm.REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER, ErrorsJvm.REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER_ERROR
|
||||
).on(reportOn, containerClass.fqNameSafe, otherNonDefault)
|
||||
return ErrorsJvm.REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER
|
||||
.on(languageVersionSettings, reportOn, containerClass.fqNameSafe, otherNonDefault)
|
||||
}
|
||||
|
||||
return null
|
||||
@@ -193,9 +191,15 @@ class RepeatableAnnotationChecker(
|
||||
val annotationRetention = annotationClass.getAnnotationRetention() ?: KotlinRetention.RUNTIME
|
||||
val containerRetention = containerClass.getAnnotationRetention() ?: KotlinRetention.RUNTIME
|
||||
if (containerRetention > annotationRetention) {
|
||||
return select(
|
||||
ErrorsJvm.REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION, ErrorsJvm.REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_ERROR
|
||||
).on(reportOn, containerClass.fqNameSafe, containerRetention.name, annotationClass.fqNameSafe, annotationRetention.name)
|
||||
return ErrorsJvm.REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION
|
||||
.on(
|
||||
languageVersionSettings,
|
||||
reportOn,
|
||||
containerClass.fqNameSafe,
|
||||
containerRetention.name,
|
||||
annotationClass.fqNameSafe,
|
||||
annotationRetention.name
|
||||
)
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -224,21 +228,14 @@ class RepeatableAnnotationChecker(
|
||||
else -> false
|
||||
}
|
||||
if (!ok) {
|
||||
return select(
|
||||
ErrorsJvm.REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET, ErrorsJvm.REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET_ERROR
|
||||
).on(reportOn, containerClass.fqNameSafe, annotationClass.fqNameSafe)
|
||||
return ErrorsJvm.REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET
|
||||
.on(languageVersionSettings, reportOn, containerClass.fqNameSafe, annotationClass.fqNameSafe)
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
private fun <D> select(warning: D, error: D): D =
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.RepeatableAnnotationContainerConstraints))
|
||||
error
|
||||
else
|
||||
warning
|
||||
|
||||
private fun isRepeatableAnnotation(classDescriptor: ClassDescriptor): Boolean =
|
||||
classDescriptor.isAnnotatedWithKotlinRepeatable() || platformAnnotationFeaturesSupport.isRepeatableAnnotationClass(classDescriptor)
|
||||
|
||||
|
||||
-5
@@ -76,15 +76,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES, "Annotation ''@{0}'' is not applicable to the multi-file classes", TO_STRING);
|
||||
|
||||
MAP.put(REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY, "Container annotation ''{0}'' must have a property ''value'' of type ''Array<{1}>''. This code will be prohibited in Kotlin 1.6", TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_ERROR, "Container annotation ''{0}'' must have a property ''value'' of type ''Array<{1}>''", TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER, "Container annotation ''{0}'' does not have a default value for ''{1}''. This code will be prohibited in Kotlin 1.6", TO_STRING, NAME);
|
||||
MAP.put(REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER_ERROR, "Container annotation ''{0}'' does not have a default value for ''{1}''", TO_STRING, NAME);
|
||||
MAP.put(REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION, "Container annotation ''{0}'' has shorter retention (''{1}'') than the repeatable annotation ''{2}'' (''{3}''). This code will be prohibited in Kotlin 1.6", TO_STRING, TO_STRING, TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_ERROR, "Container annotation ''{0}'' has shorter retention (''{1}'') than the repeatable annotation ''{2}'' (''{3}'')", TO_STRING, TO_STRING, TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET, "Target set of container annotation ''{0}'' must be a subset of the target set of contained annotation ''{1}''. This code will be prohibited in Kotlin 1.6", TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET_ERROR, "Target set of container annotation ''{0}'' must be a subset of the target set of contained annotation ''{1}''", TO_STRING, TO_STRING);
|
||||
MAP.put(REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER, "Repeatable annotation cannot have a nested class named 'Container'. This name is reserved for auto-generated container class");
|
||||
MAP.put(REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER_ERROR, "Repeatable annotation cannot have a nested class named 'Container'. This name is reserved for auto-generated container class");
|
||||
|
||||
MAP.put(JVM_PACKAGE_NAME_CANNOT_BE_EMPTY, "''@JvmPackageName'' annotation value cannot be empty");
|
||||
MAP.put(JVM_PACKAGE_NAME_MUST_BE_VALID_NAME, "''@JvmPackageName'' annotation value must be a valid dot-qualified name of a package");
|
||||
|
||||
+5
-10
@@ -75,16 +75,11 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory0<KtAnnotationEntry> REPEATED_ANNOTATION_TARGET6 = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, FqName> REPEATED_ANNOTATION_WITH_CONTAINER = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, Named> REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, Named> REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory4<KtAnnotationEntry, FqName, String, FqName, String> REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION = DiagnosticFactory4.create(WARNING);
|
||||
DiagnosticFactory4<KtAnnotationEntry, FqName, String, FqName, String> REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_ERROR = DiagnosticFactory4.create(ERROR);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtAnnotationEntry> REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER_ERROR = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactoryForDeprecation2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY = DiagnosticFactoryForDeprecation2.create(LanguageFeature.RepeatableAnnotationContainerConstraints);
|
||||
DiagnosticFactoryForDeprecation2<KtAnnotationEntry, FqName, Named> REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER = DiagnosticFactoryForDeprecation2.create(LanguageFeature.RepeatableAnnotationContainerConstraints);
|
||||
DiagnosticFactoryForDeprecation4<KtAnnotationEntry, FqName, String, FqName, String> REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION = DiagnosticFactoryForDeprecation4.create(LanguageFeature.RepeatableAnnotationContainerConstraints);
|
||||
DiagnosticFactoryForDeprecation2<KtAnnotationEntry, FqName, FqName> REPEATABLE_CONTAINER_TARGET_SET_NOT_A_SUBSET = DiagnosticFactoryForDeprecation2.create(LanguageFeature.RepeatableAnnotationContainerConstraints);
|
||||
DiagnosticFactoryForDeprecation0<KtAnnotationEntry> REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER = DiagnosticFactoryForDeprecation0.create(LanguageFeature.RepeatableAnnotationContainerConstraints);
|
||||
|
||||
DiagnosticFactory1<KtAnnotationEntry, FqName> ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
|
||||
+6
-6
@@ -3,27 +3,27 @@
|
||||
|
||||
import java.lang.annotation.Repeatable as R
|
||||
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY!>@R(C1::class)<!>
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_WARNING!>@R(C1::class)<!>
|
||||
annotation class A1
|
||||
annotation class C1
|
||||
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY!>@R(C2::class)<!>
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_WARNING!>@R(C2::class)<!>
|
||||
annotation class A2
|
||||
annotation class C2(val value: A2)
|
||||
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY!>@R(C3::class)<!>
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_WARNING!>@R(C3::class)<!>
|
||||
annotation class A3
|
||||
annotation class C3(val value: Array<String>)
|
||||
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY!>@R(C4::class)<!>
|
||||
<!REPEATABLE_CONTAINER_MUST_HAVE_VALUE_ARRAY_WARNING!>@R(C4::class)<!>
|
||||
annotation class A4
|
||||
annotation class C4(val notValue: Array<A4>)
|
||||
|
||||
<!REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER!>@R(C5::class)<!>
|
||||
<!REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER_WARNING!>@R(C5::class)<!>
|
||||
annotation class A5
|
||||
annotation class C5(val value: Array<A5>, val irrelevant: String)
|
||||
|
||||
<!REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER!>@R(C6::class)<!>
|
||||
<!REPEATABLE_CONTAINER_HAS_NON_DEFAULT_PARAMETER_WARNING!>@R(C6::class)<!>
|
||||
annotation class A6
|
||||
annotation class C6(val irrelevant: Double, val value: Array<A6> = [])
|
||||
|
||||
|
||||
+3
-3
@@ -4,19 +4,19 @@
|
||||
import java.lang.annotation.Repeatable as R
|
||||
import kotlin.annotation.AnnotationRetention.*
|
||||
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION!>@R(C1::class)<!>
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_WARNING!>@R(C1::class)<!>
|
||||
@Retention(RUNTIME)
|
||||
annotation class A1
|
||||
@Retention(BINARY)
|
||||
annotation class C1(val value: Array<A1>)
|
||||
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION!>@R(C2::class)<!>
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_WARNING!>@R(C2::class)<!>
|
||||
@Retention(BINARY)
|
||||
annotation class A2
|
||||
@Retention(SOURCE)
|
||||
annotation class C2(val value: Array<A2>)
|
||||
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION!>@R(C3::class)<!>
|
||||
<!REPEATABLE_CONTAINER_HAS_SHORTER_RETENTION_WARNING!>@R(C3::class)<!>
|
||||
annotation class A3
|
||||
@Retention(SOURCE)
|
||||
annotation class C3(val value: Array<A3>)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !LANGUAGE: -RepeatableAnnotations -RepeatableAnnotationContainerConstraints
|
||||
// FULL_JDK
|
||||
|
||||
<!REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER!>@Repeatable<!>
|
||||
<!REPEATABLE_ANNOTATION_HAS_NESTED_CLASS_NAMED_CONTAINER_WARNING!>@Repeatable<!>
|
||||
annotation class A1 {
|
||||
class Container
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user