Don't fail on annotated built-ins
Unit.VALUE is annotated right now (with "suppress"), so deserialization was throwing an exception from AnnotationDeserializer.UNSUPPORTED. Return empty collections of annotations instead; here we use the fact that it's the only annotation in built-ins and its presence is useless to the type checker
This commit is contained in:
+31
@@ -60,6 +60,37 @@ public interface AnnotationDeserializer {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AnnotationDeserializer EMPTY = new AnnotationDeserializer() {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) {
|
||||||
|
return Annotations.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Annotations loadCallableAnnotations(
|
||||||
|
@NotNull ClassOrPackageFragmentDescriptor container,
|
||||||
|
@NotNull ProtoBuf.Callable proto,
|
||||||
|
@NotNull NameResolver nameResolver,
|
||||||
|
@NotNull AnnotatedCallableKind kind
|
||||||
|
) {
|
||||||
|
return Annotations.EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Annotations loadValueParameterAnnotations(
|
||||||
|
@NotNull ClassOrPackageFragmentDescriptor container,
|
||||||
|
@NotNull ProtoBuf.Callable callable,
|
||||||
|
@NotNull NameResolver nameResolver,
|
||||||
|
@NotNull AnnotatedCallableKind kind,
|
||||||
|
@NotNull ProtoBuf.Callable.ValueParameter proto
|
||||||
|
) {
|
||||||
|
return Annotations.EMPTY;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
enum AnnotatedCallableKind {
|
enum AnnotatedCallableKind {
|
||||||
FUNCTION,
|
FUNCTION,
|
||||||
PROPERTY,
|
PROPERTY,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import jet.Function0;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.descriptors.serialization.*;
|
import org.jetbrains.jet.descriptors.serialization.*;
|
||||||
|
import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer;
|
||||||
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope;
|
import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
|
||||||
@@ -24,8 +25,6 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeserializer.UNSUPPORTED;
|
|
||||||
|
|
||||||
class BuiltinsPackageFragment extends DeclarationDescriptorImpl implements PackageFragmentDescriptor {
|
class BuiltinsPackageFragment extends DeclarationDescriptorImpl implements PackageFragmentDescriptor {
|
||||||
private final DeserializedPackageMemberScope members;
|
private final DeserializedPackageMemberScope members;
|
||||||
private final NameResolver nameResolver;
|
private final NameResolver nameResolver;
|
||||||
@@ -39,8 +38,9 @@ class BuiltinsPackageFragment extends DeclarationDescriptorImpl implements Packa
|
|||||||
|
|
||||||
packageFragmentProvider = new BuiltinsPackageFragmentProvider();
|
packageFragmentProvider = new BuiltinsPackageFragmentProvider();
|
||||||
|
|
||||||
members = new DeserializedPackageMemberScope(storageManager, this, UNSUPPORTED, new BuiltInsDescriptorFinder(storageManager),
|
// TODO: support annotations
|
||||||
loadPackage(), nameResolver);
|
members = new DeserializedPackageMemberScope(storageManager, this, AnnotationDeserializer.EMPTY,
|
||||||
|
new BuiltInsDescriptorFinder(storageManager), loadPackage(), nameResolver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -133,7 +133,8 @@ class BuiltinsPackageFragment extends DeclarationDescriptorImpl implements Packa
|
|||||||
private final NotNullLazyValue<Collection<Name>> classNames;
|
private final NotNullLazyValue<Collection<Name>> classNames;
|
||||||
|
|
||||||
public BuiltInsDescriptorFinder(@NotNull StorageManager storageManager) {
|
public BuiltInsDescriptorFinder(@NotNull StorageManager storageManager) {
|
||||||
super(storageManager, UNSUPPORTED, packageFragmentProvider);
|
// TODO: support annotations
|
||||||
|
super(storageManager, AnnotationDeserializer.EMPTY, packageFragmentProvider);
|
||||||
|
|
||||||
classNames = storageManager.createLazyValue(new Function0<Collection<Name>>() {
|
classNames = storageManager.createLazyValue(new Function0<Collection<Name>>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user