jet.Annotation

Create a supertype for all Kotlin annotations, jet.Annotation.
Map java.lang.annotation.Annotation to jet.Annotation and vice versa.
Add extension function "annotationType()" to every annotation, similar to java.lang.annotation.Annotation.annotationType()
 #KT-1620 Fixed
This commit is contained in:
Alexander Udalov
2012-08-24 22:07:55 +04:00
parent 9be4f63735
commit d99ffbd120
12 changed files with 84 additions and 15 deletions
+4 -2
View File
@@ -1,7 +1,9 @@
package jet
public annotation class volatile
public annotation class atomic
public trait Annotation
public annotation class volatile : Annotation
public annotation class atomic : Annotation
public fun <R> synchronized(lock: Any, block : () -> R) : R
@@ -170,6 +170,9 @@ public class DescriptorResolver {
return ErrorUtils.createErrorType("Supertype not specified");
}
}
else if (jetClass instanceof JetClass && ((JetClass) jetClass).isAnnotation()) {
return JetStandardLibrary.getInstance().getAnnotationType();
}
return JetStandardClasses.getAnyType();
}
@@ -98,10 +98,11 @@ public class JetStandardLibrary {
private ClassDescriptor comparableClass;
private ClassDescriptor throwableClass;
private ClassDescriptor enumClass;
private ClassDescriptor annotationClass;
private ClassDescriptor volatileClass;
private JetType stringType;
private JetType annotationType;
private JetType tuple0Type;
private EnumMap<PrimitiveType, ClassDescriptor> primitiveTypeToClass;
@@ -180,6 +181,9 @@ public class JetStandardLibrary {
this.stringType = new JetTypeImpl(getString());
this.tuple0Type = new JetTypeImpl(JetStandardClasses.getTuple(0));
this.annotationClass = getStdClassByName("Annotation");
this.annotationType = new JetTypeImpl(annotationClass);
primitiveTypeToClass = new EnumMap<PrimitiveType, ClassDescriptor>(PrimitiveType.class);
primitiveTypeToJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
primitiveTypeToNullableJetType = new EnumMap<PrimitiveType, JetType>(PrimitiveType.class);
@@ -345,6 +349,18 @@ public class JetStandardLibrary {
return enumClass;
}
@NotNull
public ClassDescriptor getAnnotation() {
initStdClasses();
return annotationClass;
}
@NotNull
public JetType getAnnotationType() {
initStdClasses();
return annotationType;
}
@NotNull
public JetType getPrimitiveJetType(PrimitiveType primitiveType) {
return primitiveTypeToJetType.get(primitiveType);