Present "data" annotation to standard library
This commit is contained in:
@@ -4,6 +4,7 @@ public trait Annotation
|
|||||||
|
|
||||||
public annotation class volatile : Annotation
|
public annotation class volatile : Annotation
|
||||||
public annotation class atomic : Annotation
|
public annotation class atomic : Annotation
|
||||||
|
public annotation class data : Annotation
|
||||||
|
|
||||||
public fun <R> synchronized(lock: Any, block : () -> R) : R
|
public fun <R> synchronized(lock: Any, block : () -> R) : R
|
||||||
|
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ public class JetStandardLibrary {
|
|||||||
private ClassDescriptor enumClass;
|
private ClassDescriptor enumClass;
|
||||||
private ClassDescriptor annotationClass;
|
private ClassDescriptor annotationClass;
|
||||||
private ClassDescriptor volatileClass;
|
private ClassDescriptor volatileClass;
|
||||||
|
private ClassDescriptor dataClass;
|
||||||
|
|
||||||
private JetType stringType;
|
private JetType stringType;
|
||||||
private JetType annotationType;
|
private JetType annotationType;
|
||||||
@@ -170,7 +171,9 @@ public class JetStandardLibrary {
|
|||||||
this.arrayClass = getStdClassByName("Array");
|
this.arrayClass = getStdClassByName("Array");
|
||||||
this.throwableClass = getStdClassByName("Throwable");
|
this.throwableClass = getStdClassByName("Throwable");
|
||||||
this.enumClass = getStdClassByName("Enum");
|
this.enumClass = getStdClassByName("Enum");
|
||||||
|
|
||||||
this.volatileClass = getStdClassByName("volatile");
|
this.volatileClass = getStdClassByName("volatile");
|
||||||
|
this.dataClass = getStdClassByName("data");
|
||||||
|
|
||||||
this.iterableClass = getStdClassByName("Iterable");
|
this.iterableClass = getStdClassByName("Iterable");
|
||||||
this.iteratorClass = getStdClassByName("Iterator");
|
this.iteratorClass = getStdClassByName("Iterator");
|
||||||
@@ -498,6 +501,11 @@ public class JetStandardLibrary {
|
|||||||
return getEnumType(Variance.INVARIANT, argument);
|
return getEnumType(Variance.INVARIANT, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public ClassDescriptor getDataClassAnnotation() {
|
||||||
|
return dataClass;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) {
|
public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) {
|
||||||
List<TypeProjection> types = Collections.singletonList(new TypeProjection(projectionType, argument));
|
List<TypeProjection> types = Collections.singletonList(new TypeProjection(projectionType, argument));
|
||||||
@@ -559,10 +567,24 @@ public class JetStandardLibrary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVolatile(@NotNull PropertyDescriptor descriptor) {
|
public boolean isVolatile(@NotNull PropertyDescriptor descriptor) {
|
||||||
|
return containsAnnotation(descriptor, volatileClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isData(@NotNull ClassDescriptor descriptor) {
|
||||||
|
if (initializing) {
|
||||||
|
// This is a hack to make this method callable while resolving standard library
|
||||||
|
// (otherwise getInstance() would throw an Exception)
|
||||||
|
// This also means that "data" annotation has no effect in standard library
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return containsAnnotation(descriptor, getInstance().dataClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean containsAnnotation(DeclarationDescriptor descriptor, ClassDescriptor annotationClass) {
|
||||||
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
||||||
if (annotations != null) {
|
if (annotations != null) {
|
||||||
for(AnnotationDescriptor annotation: annotations) {
|
for (AnnotationDescriptor annotation : annotations) {
|
||||||
if (volatileClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) {
|
if (annotationClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1447,6 +1447,9 @@ public final class jet.Tuple9</*0*/ out T1 : jet.Any?, /*1*/ out T2 : jet.Any?,
|
|||||||
public final annotation class jet.atomic : jet.Annotation {
|
public final annotation class jet.atomic : jet.Annotation {
|
||||||
public final /*constructor*/ fun <init>(): jet.atomic
|
public final /*constructor*/ fun <init>(): jet.atomic
|
||||||
}
|
}
|
||||||
|
public final annotation class jet.data : jet.Annotation {
|
||||||
|
public final /*constructor*/ fun <init>(): jet.data
|
||||||
|
}
|
||||||
public final annotation class jet.volatile : jet.Annotation {
|
public final annotation class jet.volatile : jet.Annotation {
|
||||||
public final /*constructor*/ fun <init>(): jet.volatile
|
public final /*constructor*/ fun <init>(): jet.volatile
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user