Targeting / retention for a set of standard annotations, some inapplicable annotation checks replaced with target check, some fixed tests

This commit is contained in:
Mikhail Glukhikh
2015-07-16 11:35:28 +03:00
parent a75daf85e2
commit 94a00540be
53 changed files with 213 additions and 206 deletions
@@ -96,10 +96,6 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker {
if (declaration is JetNamedFunction || declaration is JetProperty || declaration is JetPropertyAccessor) {
checkDeclaration(declaration, descriptor, diagnosticHolder)
}
else {
//TODO: there should be general mechanism
diagnosticHolder.report(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE.on(declaration, descriptor));
}
}
}
@@ -172,10 +168,8 @@ public class PublicFieldAnnotationChecker: DeclarationChecker {
diagnosticHolder.report(ErrorsJvm.INAPPLICABLE_PUBLIC_FIELD.on(annotationEntry))
}
if (descriptor !is PropertyDescriptor) {
report()
}
else if (!bindingContext.get<PropertyDescriptor, Boolean>(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) {
if (descriptor is PropertyDescriptor
&& !bindingContext.get<PropertyDescriptor, Boolean>(BindingContext.BACKING_FIELD_REQUIRED, descriptor)!!) {
report()
}
}
@@ -58,10 +58,7 @@ public class NativeFunChecker : DeclarationChecker {
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT.on(declaration))
}
if (descriptor is ConstructorDescriptor) {
diagnosticHolder.report(Errors.INAPPLICABLE_ANNOTATION.on(declaration));
}
else if (declaration is JetDeclarationWithBody && declaration.hasBody()) {
if (descriptor !is ConstructorDescriptor && declaration is JetDeclarationWithBody && declaration.hasBody()) {
diagnosticHolder.report(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY.on(declaration))
}
@@ -47,7 +47,6 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be 'platformStatic' in object");
MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES);
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "''jvmOverloads'' annotation has no effect for methods without default arguments");
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''jvmOverloads'' annotation cannot be used on abstract methods");
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''jvmOverloads'' annotation has no effect on private and local declarations");
@@ -43,7 +43,6 @@ public interface ErrorsJvm {
DiagnosticFactory0<JetDeclaration> OVERRIDE_CANNOT_BE_STATIC = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> PLATFORM_STATIC_NOT_IN_OBJECT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory1<JetDeclaration, DeclarationDescriptor> PLATFORM_STATIC_ILLEGAL_USAGE = DiagnosticFactory1.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
DiagnosticFactory0<JetDeclaration> OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);