Synchronized is no more allowed on abstract functions
This commit is contained in:
+15
@@ -143,6 +143,21 @@ public class VolatileAnnotationChecker : DeclarationChecker {
|
||||
}
|
||||
}
|
||||
|
||||
public class SynchronizedAnnotationChecker : DeclarationChecker {
|
||||
|
||||
override fun check(declaration: JetDeclaration,
|
||||
descriptor: DeclarationDescriptor,
|
||||
diagnosticHolder: DiagnosticSink,
|
||||
bindingContext: BindingContext
|
||||
) {
|
||||
val synchronizedAnnotation = DescriptorUtils.getSynchronizedAnnotation(descriptor)
|
||||
if (synchronizedAnnotation != null && descriptor is FunctionDescriptor && descriptor.modality == Modality.ABSTRACT) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(synchronizedAnnotation) ?: return
|
||||
diagnosticHolder.report(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT.on(annotationEntry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class OverloadsAnnotationChecker: DeclarationChecker {
|
||||
override fun check(
|
||||
declaration: JetDeclaration,
|
||||
|
||||
+1
@@ -54,6 +54,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "''JvmName'' annotation is not applicable to this declaration");
|
||||
MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name");
|
||||
MAP.put(ErrorsJvm.VOLATILE_ON_VALUE, "''Volatile'' annotation cannot be used on immutable properties");
|
||||
MAP.put(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT, "''Synchronized'' annotation cannot be used on abstract functions");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body");
|
||||
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external");
|
||||
|
||||
@@ -51,6 +51,7 @@ public interface ErrorsJvm {
|
||||
DiagnosticFactory1<JetAnnotationEntry, String> INAPPLICABLE_JVM_FIELD = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetAnnotationEntry> VOLATILE_ON_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetAnnotationEntry> SYNCHRONIZED_ON_ABSTRACT = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<JetDeclaration> OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<JetDeclaration> OVERLOADS_ABSTRACT = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ public object JvmPlatformConfigurator : PlatformConfigurator(
|
||||
PlatformStaticAnnotationChecker(),
|
||||
JvmNameAnnotationChecker(),
|
||||
VolatileAnnotationChecker(),
|
||||
SynchronizedAnnotationChecker(),
|
||||
LocalFunInlineChecker(),
|
||||
ReifiedTypeParameterAnnotationChecker(),
|
||||
NativeFunChecker(),
|
||||
|
||||
Reference in New Issue
Block a user