Stub support for annotations

This commit is contained in:
Andrey Breslav
2013-05-31 17:42:46 +04:00
committed by Alexander Udalov
parent 557fdfcd56
commit 4f12a3d86e
10 changed files with 290 additions and 662 deletions
@@ -101,14 +101,13 @@ message Class {
/*
Visibility
Modality
has_annotation
ClassKind
is_inner
*/
optional int32 flags = 1 [default = 0 /*internal final class*/];
optional int32 flags = 1 [default = 0 /*internal final class, no annotations*/];
optional string extra_visibility = 2; // for things like java-specific visibilities
repeated Annotation annotations = 3;
required int32 name = 4;
repeated TypeParameter typeParameters = 5;
@@ -147,17 +146,17 @@ message Callable {
/*
Visibility
Modality
has_annotations
fun/val/var/constructor
Kind
inline
setter::Modality
setter::Visibility
setter::has_annotations
*/
optional int32 flags = 1;
optional string extra_visibility = 2; // for things like java-specific visibilities
repeated Annotation annotations = 3;
repeated TypeParameter typeParameters = 4;
optional Type receiverType = 5;
@@ -167,6 +166,7 @@ message Callable {
message ValueParameter {
/*
declaresDefault
has_annotations
*/
optional int32 flags = 1;
required int32 name = 2;
@@ -194,8 +194,4 @@ enum Visibility {
PROTECTED = 0x02;
PUBLIC = 0x03;
EXTRA = 0x04; // there's an extra field for the actual visibility
}
message Annotation {
// TODO ???
}
@@ -18,6 +18,7 @@ package org.jetbrains.jet.descriptors.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
@@ -31,9 +32,11 @@ public abstract class AbstractClassResolver implements ClassResolver {
private final NameResolver nameResolver;
private final NestedClassResolver nestedClassResolver;
private final MemoizedFunctionToNotNull<ClassId, ClassDescriptor> findClass;
private final AnnotationDeserializer annotationDeserializer;
public AbstractClassResolver(@NotNull NameResolver nameResolver) {
public AbstractClassResolver(@NotNull NameResolver nameResolver, @NotNull AnnotationDeserializer annotationDeserializer) {
this.nameResolver = nameResolver;
this.annotationDeserializer = annotationDeserializer;
this.nestedClassResolver = new NestedClassResolver() {
@Nullable
@@ -55,11 +58,14 @@ public abstract class AbstractClassResolver implements ClassResolver {
protected ClassDescriptor doCompute(ClassId classId) {
ProtoBuf.Class classProto = getClassProto(classId);
assert classProto != null : "No class found: " + classId;
DeclarationDescriptor owner =
classId.isTopLevelClass() ? getPackage(classId.getPackageFqName()) : findClass(classId.getOuterClassId());
assert owner != null : "No owner found for " + classId;
AbstractClassResolver outer = AbstractClassResolver.this;
ClassDescriptor classDescriptor = new DeserializedClassDescriptor(
owner, AbstractClassResolver.this.nameResolver, AbstractClassResolver.this, nestedClassResolver, classProto, null
owner, outer.nameResolver, outer.annotationDeserializer, outer, nestedClassResolver, classProto, null
);
classDescriptorCreated(classDescriptor);
return classDescriptor;
@@ -17,6 +17,7 @@
package org.jetbrains.jet.descriptors.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.Modality;
import org.jetbrains.jet.lang.descriptors.Visibility;
@@ -36,32 +37,38 @@ public class DescriptorDeserializer {
public static DescriptorDeserializer create(
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull NameResolver nameResolver,
@NotNull ClassResolver classResolver
@NotNull ClassResolver classResolver,
@NotNull AnnotationDeserializer annotationDeserializer
) {
return new DescriptorDeserializer(new TypeDeserializer(null, nameResolver, classResolver), containingDeclaration, nameResolver);
return new DescriptorDeserializer(new TypeDeserializer(null, nameResolver, classResolver), containingDeclaration, nameResolver,
annotationDeserializer);
}
@NotNull
public static DescriptorDeserializer create(
@NotNull TypeDeserializer typeDeserializer,
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull NameResolver nameResolver
@NotNull NameResolver nameResolver,
@NotNull AnnotationDeserializer annotationDeserializer
) {
return new DescriptorDeserializer(typeDeserializer, containingDeclaration, nameResolver);
return new DescriptorDeserializer(typeDeserializer, containingDeclaration, nameResolver, annotationDeserializer);
}
private final DeclarationDescriptor containingDeclaration;
private final NameResolver nameResolver;
private final TypeDeserializer typeDeserializer;
private final AnnotationDeserializer annotationDeserializer;
private DescriptorDeserializer(
@NotNull TypeDeserializer typeDeserializer,
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull NameResolver nameResolver
@NotNull NameResolver nameResolver,
@NotNull AnnotationDeserializer annotationDeserializer
) {
this.typeDeserializer = typeDeserializer;
this.containingDeclaration = containingDeclaration;
this.nameResolver = nameResolver;
this.annotationDeserializer = annotationDeserializer;
}
@NotNull
@@ -71,7 +78,7 @@ public class DescriptorDeserializer {
@NotNull
private DescriptorDeserializer createChildDeserializer(@NotNull DeclarationDescriptor descriptor) {
return create(new TypeDeserializer(typeDeserializer), descriptor, nameResolver);
return create(new TypeDeserializer(typeDeserializer), descriptor, nameResolver, annotationDeserializer);
}
@NotNull
@@ -94,8 +101,7 @@ public class DescriptorDeserializer {
int flags = proto.getFlags();
PropertyDescriptorImpl property = new PropertyDescriptorImpl(
containingDeclaration,
// TODO: annotations
Collections.<AnnotationDescriptor>emptyList(),
getAnnotations(proto),
modality(Flags.getModality(flags)),
visibility(Flags.getVisibility(flags)),
Flags.getCallableKind(flags) == Callable.CallableKind.VAR,
@@ -119,8 +125,7 @@ public class DescriptorDeserializer {
int flags = proto.getFlags();
SimpleFunctionDescriptorImpl function = new SimpleFunctionDescriptorImpl(
containingDeclaration,
// TODO: annotations
Collections.<AnnotationDescriptor>emptyList(),
getAnnotations(proto),
nameResolver.getName(proto.getName()),
memberKind(Flags.getMemberKind(flags))
);
@@ -146,8 +151,7 @@ public class DescriptorDeserializer {
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
ConstructorDescriptorImpl descriptor = new ConstructorDescriptorImpl(
classDescriptor,
// TODO
Collections.<AnnotationDescriptor>emptyList(),
getAnnotations(proto),
// TODO: primary
true);
DescriptorDeserializer local = createChildDeserializer(descriptor);
@@ -160,6 +164,12 @@ public class DescriptorDeserializer {
return descriptor;
}
private List<AnnotationDescriptor> getAnnotations(Callable proto) {
return Flags.hasAnnotations(proto.getFlags())
? annotationDeserializer.loadCallableAnnotations(proto)
: Collections.<AnnotationDescriptor>emptyList();
}
private static CallableMemberDescriptor.Kind memberKind(Callable.MemberKind memberKind) {
switch (memberKind) {
case DECLARATION:
@@ -247,7 +257,7 @@ public class DescriptorDeserializer {
int id = proto.getId();
TypeParameterDescriptorImpl descriptor = TypeParameterDescriptorImpl.createForFurtherModification(
containingDeclaration,
// TODO
// TODO (type parameter annotations are not supported in Java 7)
Collections.<AnnotationDescriptor>emptyList(),
proto.getReified(),
variance(proto.getVariance()),
@@ -291,11 +301,16 @@ public class DescriptorDeserializer {
return new ValueParameterDescriptorImpl(
containingDeclaration,
index,
// TODO
Collections.<AnnotationDescriptor>emptyList(),
getAnnotations(proto),
nameResolver.getName(proto.getName()),
typeDeserializer.type(proto.getType()),
Flags.declaresDefaultValue(proto.getFlags()),
typeDeserializer.typeOrNull(proto.hasVarargElementType() ? proto.getVarargElementType() : null));
}
private List<AnnotationDescriptor> getAnnotations(Callable.ValueParameter proto) {
return Flags.hasAnnotations(proto.getFlags())
? annotationDeserializer.loadValueParameterAnnotations(proto)
: Collections.<AnnotationDescriptor>emptyList();
}
}
@@ -18,6 +18,7 @@ package org.jetbrains.jet.descriptors.serialization;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeConstructor;
import org.jetbrains.jet.lang.types.TypeProjection;
@@ -52,10 +53,8 @@ public class DescriptorSerializer {
public ProtoBuf.Class.Builder classProto(@NotNull ClassDescriptor classDescriptor) {
ProtoBuf.Class.Builder builder = ProtoBuf.Class.newBuilder();
// TODO annotations
int flags = Flags.getClassFlags(classDescriptor.getVisibility(), classDescriptor.getModality(), classDescriptor.getKind(),
classDescriptor.isInner());
int flags = Flags.getClassFlags(hasAnnotations(classDescriptor), classDescriptor.getVisibility(),
classDescriptor.getModality(), classDescriptor.getKind(), classDescriptor.isInner());
builder.setFlags(flags);
// TODO extra visibility
@@ -111,7 +110,8 @@ public class DescriptorSerializer {
ProtoBuf.Callable.Builder builder = ProtoBuf.Callable.newBuilder();
// TODO setter flags
builder.setFlags(Flags.getCallableFlags(descriptor.getVisibility(),
// TODO setter annotations
builder.setFlags(Flags.getCallableFlags(hasAnnotations(descriptor), descriptor.getVisibility(),
descriptor.getModality(),
descriptor.getKind(),
callableKind(descriptor),
@@ -159,7 +159,7 @@ public class DescriptorSerializer {
private ProtoBuf.Callable.ValueParameter.Builder valueParameter(ValueParameterDescriptor descriptor) {
ProtoBuf.Callable.ValueParameter.Builder builder = ProtoBuf.Callable.ValueParameter.newBuilder();
builder.setFlags(Flags.getValueParameterFlags(descriptor.declaresDefaultValue()));
builder.setFlags(Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue()));
builder.setName(nameTable.getSimpleNameIndex(descriptor.getName()));
@@ -283,4 +283,8 @@ public class DescriptorSerializer {
private int getTypeParameterId(@NotNull TypeParameterDescriptor descriptor) {
return typeParameters.intern(descriptor);
}
private static boolean hasAnnotations(Annotated descriptor) {
return !descriptor.getAnnotations().isEmpty();
}
}
@@ -8,8 +8,11 @@ public class Flags {
// Common
public static final int HAS_ANNOTATIONS_BIT_COUNT = 1;
public static final int HAS_ANNOTATIONS_OFFSET = 0;
public static final int VISIBILITY_BIT_COUNT = bitWidth(ProtoBuf.Visibility.values());
public static final int VISIBILITY_OFFSET = 0;
public static final int VISIBILITY_OFFSET = HAS_ANNOTATIONS_OFFSET + HAS_ANNOTATIONS_BIT_COUNT;
public static final int MODALITY_BIT_COUNT = bitWidth(ProtoBuf.Modality.values());
public static final int MODALITY_OFFSET = VISIBILITY_OFFSET + VISIBILITY_BIT_COUNT;
@@ -36,7 +39,7 @@ public class Flags {
// Parameters
public static final int DECLARES_DEFAULT_VALUE_BIT_COUNT = 1;
public static final int DECLARES_DEFAULT_VALUE_OFFSET = 0;
public static final int DECLARES_DEFAULT_VALUE_OFFSET = HAS_ANNOTATIONS_OFFSET + HAS_ANNOTATIONS_BIT_COUNT;
// ---
@@ -96,13 +99,25 @@ public class Flags {
return getValue(flags, BOOLEANS, DECLARES_DEFAULT_VALUE_BIT_COUNT, DECLARES_DEFAULT_VALUE_OFFSET);
}
public static int getClassFlags(Visibility visibility, Modality modality, ClassKind kind, boolean inner) {
public static boolean hasAnnotations(int flags) {
return getValue(flags, BOOLEANS, HAS_ANNOTATIONS_BIT_COUNT, HAS_ANNOTATIONS_OFFSET);
}
public static int getClassFlags(
boolean hasAnnotations,
Visibility visibility,
Modality modality,
ClassKind kind,
boolean inner
) {
int hasAnnotationsInt = hasAnnotations ? 1 : 0;
int visibilityInt = visibility(visibility).getNumber();
int modalityInt = modality(modality).getNumber();
int classKindInt = classKind(kind).getNumber();
int innerInt = inner ? 1 : 0;
return visibilityInt << VISIBILITY_OFFSET
return hasAnnotationsInt << HAS_ANNOTATIONS_OFFSET
| modalityInt << MODALITY_OFFSET
| visibilityInt << VISIBILITY_OFFSET
| classKindInt << CLASS_KIND_OFFSET
| innerInt << INNER_OFFSET
;
@@ -129,19 +144,21 @@ public class Flags {
}
public static int getCallableFlags(
@NotNull Visibility visibility,
boolean hasAnnotations, @NotNull Visibility visibility,
@NotNull Modality modality,
@NotNull CallableMemberDescriptor.Kind memberKind,
@NotNull ProtoBuf.Callable.CallableKind callableKind,
boolean inline
) {
int hasAnnotationsInt = hasAnnotations ? 1 : 0;
int visibilityInt = visibility(visibility).getNumber();
int modalityInt = modality(modality).getNumber();
int memberKindInt = memberKind(memberKind).getNumber();
int callableKindInt = callableKind.getNumber();
int inlineInt = inline ? 1 : 0;
return visibilityInt << VISIBILITY_OFFSET
return hasAnnotationsInt << HAS_ANNOTATIONS_OFFSET
| modalityInt << MODALITY_OFFSET
| visibilityInt << VISIBILITY_OFFSET
| memberKindInt << MEMBER_KIND_OFFSET
| callableKindInt << CALLABLE_KIND_OFFSET
| inlineInt << INLINE_OFFSET
@@ -193,9 +210,11 @@ public class Flags {
throw new IllegalArgumentException("Unknown member kind: " + kind);
}
public static int getValueParameterFlags(boolean declaresDefaultValue) {
public static int getValueParameterFlags(boolean hasAnnotations, boolean declaresDefaultValue) {
int hasAnnotationsInt = hasAnnotations ? 1 : 0;
int declaresDefaultValueInt = declaresDefaultValue ? 1 : 0;
return declaresDefaultValueInt << DECLARES_DEFAULT_VALUE_OFFSET
;
return hasAnnotationsInt << HAS_ANNOTATIONS_OFFSET
| declaresDefaultValueInt << DECLARES_DEFAULT_VALUE_OFFSET
;
}
}
@@ -0,0 +1,48 @@
package org.jetbrains.jet.descriptors.serialization.descriptors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.descriptors.serialization.ProtoBuf;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import java.util.List;
public interface AnnotationDeserializer {
AnnotationDeserializer UNSUPPORTED = new AnnotationDeserializer() {
@NotNull
@Override
public List<AnnotationDescriptor> loadClassAnnotations(
@NotNull ProtoBuf.Class classProto
) {
throw new UnsupportedOperationException("Annotations are not supported");
}
@NotNull
@Override
public List<AnnotationDescriptor> loadCallableAnnotations(
@NotNull ProtoBuf.Callable callableProto
) {
throw new UnsupportedOperationException("Annotations are not supported");
}
@NotNull
@Override
public List<AnnotationDescriptor> loadValueParameterAnnotations(
@NotNull ProtoBuf.Callable.ValueParameter parameterProto
) {
throw new UnsupportedOperationException("Annotations are not supported");
}
};
@NotNull
List<AnnotationDescriptor> loadClassAnnotations(@NotNull ProtoBuf.Class classProto);
@NotNull
List<AnnotationDescriptor> loadCallableAnnotations(
@NotNull ProtoBuf.Callable callableProto
);
@NotNull
List<AnnotationDescriptor> loadValueParameterAnnotations(
@NotNull ProtoBuf.Callable.ValueParameter parameterProto
);
}
@@ -25,9 +25,7 @@ import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorBase;
import org.jetbrains.jet.lang.descriptors.impl.ReceiverParameterDescriptorImpl;
import org.jetbrains.jet.lang.resolve.OverrideResolver;
import org.jetbrains.jet.lang.resolve.TraceUtil;
import org.jetbrains.jet.lang.resolve.lazy.storage.MemoizedFunctionToNullableImpl;
import org.jetbrains.jet.lang.resolve.lazy.storage.NullableLazyValue;
import org.jetbrains.jet.lang.resolve.lazy.storage.NullableLazyValueImpl;
import org.jetbrains.jet.lang.resolve.lazy.storage.*;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
@@ -46,6 +44,9 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
private final NullableLazyValue<ConstructorDescriptor> primaryConstructor;
private final AnnotationDeserializer annotationDeserializer;
private final NotNullLazyValue<List<AnnotationDescriptor>> annotations;
private final NestedClassResolver nestedClassResolver;
private final NullableLazyValue<ClassDescriptor> classObjectDescriptor;
@@ -63,6 +64,7 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
public DeserializedClassDescriptor(
@NotNull DeclarationDescriptor containingDeclaration,
@NotNull NameResolver nameResolver,
@NotNull AnnotationDeserializer annotationResolver,
@NotNull ClassResolver classResolver,
@NotNull NestedClassResolver _nestedClassResolver,
@NotNull ProtoBuf.Class classProto,
@@ -70,7 +72,7 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
) {
this.classProto = classProto;
this.typeDeserializer = new TypeDeserializer(outerTypeDeserializer, nameResolver, classResolver);
this.deserializer = DescriptorDeserializer.create(typeDeserializer, this, nameResolver);
this.deserializer = DescriptorDeserializer.create(typeDeserializer, this, nameResolver, annotationResolver);
this.containingDeclaration = containingDeclaration;
this.typeConstructor = new DeserializedClassTypeConstructor();
@@ -84,6 +86,15 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
this.kind = DescriptorDeserializer.classKind(Flags.getClassKind(flags));
this.isInner = Flags.isInner(flags);
this.annotationDeserializer = annotationResolver;
this.annotations = new NotNullLazyValueImpl<List<AnnotationDescriptor>>() {
@NotNull
@Override
protected List<AnnotationDescriptor> doCompute() {
return computeAnnotations();
}
};
this.primaryConstructor = new NullableLazyValueImpl<ConstructorDescriptor>() {
@Override
protected ConstructorDescriptor doCompute() {
@@ -169,9 +180,16 @@ public class DeserializedClassDescriptor extends ClassDescriptorBase implements
return name;
}
private List<AnnotationDescriptor> computeAnnotations() {
if (!Flags.hasAnnotations(classProto.getFlags())) {
return Collections.emptyList();
}
return annotationDeserializer.loadClassAnnotations(classProto);
}
@Override
public List<AnnotationDescriptor> getAnnotations() {
return Collections.emptyList(); // TODO
return annotations.compute();
}
@Override
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedClassDescriptor;
import org.jetbrains.jet.di.InjectorForJavaDescriptorResolver;
import org.jetbrains.jet.lang.descriptors.*;
@@ -49,11 +50,14 @@ import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.test.util.NamespaceComparator;
import java.io.*;
import java.util.*;
import static org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer.UNSUPPORTED;
public abstract class AbstractDescriptorSerializationTest extends KotlinTestWithEnvironment {
public static final Name TEST_PACKAGE_NAME = Name.identifier("test");
@@ -74,6 +78,35 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
}
};
public static final AnnotationDeserializer DUMMY_ANNOTATION_DESERIALIZER = new AnnotationDeserializer() {
@NotNull
@Override
public List<AnnotationDescriptor> loadClassAnnotations(
@NotNull ProtoBuf.Class classProto
) {
// This is a hack for tests: only data annotations are present in test data so far
AnnotationDescriptor annotationDescriptor = new AnnotationDescriptor();
annotationDescriptor.setAnnotationType(KotlinBuiltIns.getInstance().getDataClassAnnotation().getDefaultType());
return Collections.singletonList(annotationDescriptor);
}
@NotNull
@Override
public List<AnnotationDescriptor> loadCallableAnnotations(
@NotNull ProtoBuf.Callable callableProto
) {
throw new UnsupportedOperationException(); // TODO
}
@NotNull
@Override
public List<AnnotationDescriptor> loadValueParameterAnnotations(
@NotNull ProtoBuf.Callable.ValueParameter parameterProto
) {
throw new UnsupportedOperationException(); // TODO
}
};
@Override
protected JetCoreEnvironment createEnvironment() {
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY);
@@ -184,7 +217,7 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
}
DescriptorDeserializer deserializer =
DescriptorDeserializer.create(namespace, new NameResolver(simpleNames, qualifiedNames), classResolver);
DescriptorDeserializer.create(namespace, new NameResolver(simpleNames, qualifiedNames), classResolver, UNSUPPORTED);
for (ProtoBuf.Callable proto : callableProtos) {
CallableMemberDescriptor descriptor = deserializer.loadCallable(proto);
if (descriptor instanceof FunctionDescriptor) {
@@ -359,7 +392,8 @@ public abstract class AbstractDescriptorSerializationTest extends KotlinTestWith
};
NameResolver nameResolver = new NameResolver(classMetadata.simpleNames, classMetadata.qualifiedNames);
return new DeserializedClassDescriptor(containingDeclaration, nameResolver, this, nestedClassResolver, classMetadata.classProto, null);
return new DeserializedClassDescriptor(containingDeclaration, nameResolver, DUMMY_ANNOTATION_DESERIALIZER,
this, nestedClassResolver, classMetadata.classProto, null);
}
@Nullable
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.TestJdkKind;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
import org.jetbrains.jet.jvm.compiler.ExpectedLoadErrorsUtil;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
@@ -60,13 +61,13 @@ public class BuiltinsDeserializationTest extends KotlinTestWithEnvironment {
NamespaceComparator.Configuration configuration = NamespaceComparator.RECURSIVE.withRenderer(
new DescriptorRendererBuilder()
.setWithDefinedIn(false)
.setExcludedAnnotationClasses(Arrays.asList(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)))
.setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE)
.setVerbose(true)
.setAlwaysRenderAny(true)
.setPrettyFunctionTypes(false)
.build()
.setWithDefinedIn(false)
.setExcludedAnnotationClasses(Arrays.asList(new FqName(ExpectedLoadErrorsUtil.ANNOTATION_CLASS_NAME)))
.setOverrideRenderingPolicy(DescriptorRenderer.OverrideRenderingPolicy.RENDER_OPEN_OVERRIDE)
.setVerbose(true)
.setAlwaysRenderAny(true)
.setPrettyFunctionTypes(false)
.build()
);
NamespaceComparator.validateAndCompareNamespaces(KotlinBuiltIns.getInstance().getBuiltInsPackage(), actualNamespace, configuration, null);
}
@@ -82,7 +83,7 @@ public class BuiltinsDeserializationTest extends KotlinTestWithEnvironment {
NameResolver nameResolver = NameSerializationUtil.createNameResolver(serializer.getNameTable());
ClassResolver classResolver = new AbstractClassResolver(nameResolver) {
ClassResolver classResolver = new AbstractClassResolver(nameResolver, AnnotationDeserializer.UNSUPPORTED) {
@NotNull
@Override
@@ -177,7 +178,9 @@ public class BuiltinsDeserializationTest extends KotlinTestWithEnvironment {
NameResolver nameResolver,
ClassResolver classResolver
) {
DescriptorDeserializer descriptorDeserializer = DescriptorDeserializer.create(actualNamespace, nameResolver, classResolver);
DescriptorDeserializer descriptorDeserializer;
descriptorDeserializer =
DescriptorDeserializer.create(actualNamespace, nameResolver, classResolver, AnnotationDeserializer.UNSUPPORTED);
for (ProtoBuf.Callable callableProto : callableProtos) {
CallableMemberDescriptor callableMemberDescriptor = descriptorDeserializer.loadCallable(callableProto);
if (callableMemberDescriptor instanceof PropertyDescriptor) {