[K1] Make Volatile diagnostics applicable to kotlin.concurrent.Volatile
#KT-55628
This commit is contained in:
committed by
Space Team
parent
e93628d0e6
commit
91adb88eff
-18
@@ -168,24 +168,6 @@ class JvmNameAnnotationChecker : DeclarationChecker {
|
||||
}
|
||||
}
|
||||
|
||||
class VolatileAnnotationChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (descriptor !is PropertyDescriptor) return
|
||||
|
||||
val fieldAnnotation = descriptor.backingField?.annotations?.findAnnotation(VOLATILE_ANNOTATION_FQ_NAME)
|
||||
if (fieldAnnotation != null && !descriptor.isVar) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(fieldAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_VALUE.on(annotationEntry))
|
||||
}
|
||||
|
||||
val delegateAnnotation = descriptor.delegateField?.annotations?.findAnnotation(VOLATILE_ANNOTATION_FQ_NAME)
|
||||
if (delegateAnnotation != null) {
|
||||
val annotationEntry = DescriptorToSourceUtils.getSourceFromAnnotation(delegateAnnotation) ?: return
|
||||
context.trace.report(ErrorsJvm.VOLATILE_ON_DELEGATE.on(annotationEntry))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SynchronizedAnnotationChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
val synchronizedAnnotation = descriptor.findSynchronizedAnnotation()
|
||||
|
||||
-2
@@ -57,8 +57,6 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration");
|
||||
MAP.put(ILLEGAL_JVM_NAME, "Illegal JVM name");
|
||||
|
||||
MAP.put(VOLATILE_ON_VALUE, "'@Volatile' annotation cannot be used on immutable properties");
|
||||
MAP.put(VOLATILE_ON_DELEGATE, "'@Volatile' annotation cannot be used on delegated properties");
|
||||
MAP.put(SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions");
|
||||
MAP.put(SYNCHRONIZED_ON_INLINE, "'@Synchronized' annotation has no effect on inline functions");
|
||||
MAP.put(SYNCHRONIZED_ON_VALUE_CLASS, "'@Synchronized' annotation has no effect on value classes");
|
||||
|
||||
@@ -46,8 +46,6 @@ public interface ErrorsJvm {
|
||||
|
||||
DiagnosticFactory0<KtAnnotationEntry> STRICTFP_ON_CLASS = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
DiagnosticFactory0<KtAnnotationEntry> VOLATILE_ON_VALUE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> VOLATILE_ON_DELEGATE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtAnnotationEntry> SYNCHRONIZED_ON_ABSTRACT = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtElement> SYNCHRONIZED_ON_INLINE = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<KtElement> SYNCHRONIZED_ON_VALUE_CLASS = DiagnosticFactory0.create(WARNING);
|
||||
|
||||
-1
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.types.expressions.GenericArrayClassLiteralSupport
|
||||
object JvmPlatformConfigurator : PlatformConfiguratorBase(
|
||||
additionalDeclarationCheckers = listOf(
|
||||
JvmNameAnnotationChecker(),
|
||||
VolatileAnnotationChecker(),
|
||||
SynchronizedAnnotationChecker(),
|
||||
LocalFunInlineChecker(),
|
||||
ExternalFunChecker(),
|
||||
|
||||
Reference in New Issue
Block a user