Volatile forbidden for delegated properties (and checked for other use-site targets)

This commit is contained in:
Mikhail Glukhikh
2016-01-15 13:34:22 +03:00
parent b78d481bb1
commit ec909d0775
6 changed files with 25 additions and 10 deletions
@@ -507,7 +507,7 @@ public class DescriptorUtils {
@Nullable
public static String getJvmName(@NotNull Annotated annotated) {
AnnotationDescriptor jvmNameAnnotation = getJvmNameAnnotation(annotated.getAnnotations());
AnnotationDescriptor jvmNameAnnotation = getAnnotationByFqName(annotated.getAnnotations(), JVM_NAME);
if (jvmNameAnnotation == null) return null;
Map<ValueParameterDescriptor, ConstantValue<?>> arguments = jvmNameAnnotation.getAllValueArguments();
@@ -520,24 +520,24 @@ public class DescriptorUtils {
}
@Nullable
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotations annotations) {
AnnotationWithTarget jvmName = Annotations.Companion.findAnyAnnotation(annotations, JVM_NAME);
return jvmName == null ? null : jvmName.getAnnotation();
public static AnnotationDescriptor getAnnotationByFqName(@NotNull Annotations annotations, @NotNull FqName name) {
AnnotationWithTarget annotationWithTarget = Annotations.Companion.findAnyAnnotation(annotations, name);
return annotationWithTarget == null ? null : annotationWithTarget.getAnnotation();
}
@Nullable
public static AnnotationDescriptor getJvmNameAnnotation(@NotNull Annotated annotated) {
return getJvmNameAnnotation(annotated.getAnnotations());
return getAnnotationByFqName(annotated.getAnnotations(), JVM_NAME);
}
@Nullable
public static AnnotationDescriptor getVolatileAnnotation(@NotNull Annotated annotated) {
return annotated.getAnnotations().findAnnotation(VOLATILE);
return getAnnotationByFqName(annotated.getAnnotations(), VOLATILE);
}
@Nullable
public static AnnotationDescriptor getSynchronizedAnnotation(@NotNull Annotated annotated) {
return annotated.getAnnotations().findAnnotation(SYNCHRONIZED);
return getAnnotationByFqName(annotated.getAnnotations(), SYNCHRONIZED);
}
@NotNull