Any and Nothing have no supertypes
This commit is contained in:
committed by
Alexander Udalov
parent
d1d52086d7
commit
14058f7aed
@@ -1,3 +1,2 @@
|
||||
2
|
||||
Rニ0B
|
||||
Rニ0B
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
Η2
|
||||
RΒ0B
|
||||
ΗRΒ0B
|
||||
r
|
||||
+16
-5
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||
@@ -45,18 +47,24 @@ public class DescriptorSerializer {
|
||||
};
|
||||
private final NameTable nameTable;
|
||||
private final Interner<TypeParameterDescriptor> typeParameters;
|
||||
private final Predicate<ClassDescriptor> isSpecial;
|
||||
|
||||
public DescriptorSerializer(@NotNull NameTable.Namer namer) {
|
||||
this(new NameTable(namer), new Interner<TypeParameterDescriptor>());
|
||||
this(namer, Predicates.<ClassDescriptor>alwaysFalse());
|
||||
}
|
||||
|
||||
private DescriptorSerializer(NameTable nameTable, Interner<TypeParameterDescriptor> typeParameters) {
|
||||
public DescriptorSerializer(@NotNull NameTable.Namer namer, @NotNull Predicate<ClassDescriptor> isSpecial) {
|
||||
this(new NameTable(namer), new Interner<TypeParameterDescriptor>(), isSpecial);
|
||||
}
|
||||
|
||||
private DescriptorSerializer(NameTable nameTable, Interner<TypeParameterDescriptor> typeParameters, Predicate<ClassDescriptor> isSpecial) {
|
||||
this.nameTable = nameTable;
|
||||
this.typeParameters = typeParameters;
|
||||
this.isSpecial = isSpecial;
|
||||
}
|
||||
|
||||
private DescriptorSerializer createChildSerializer() {
|
||||
return new DescriptorSerializer(nameTable, new Interner<TypeParameterDescriptor>(typeParameters));
|
||||
return new DescriptorSerializer(nameTable, new Interner<TypeParameterDescriptor>(typeParameters), Predicates.<ClassDescriptor>alwaysFalse());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -82,8 +90,11 @@ public class DescriptorSerializer {
|
||||
builder.addTypeParameters(local.typeParameter(typeParameterDescriptor));
|
||||
}
|
||||
|
||||
for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
builder.addSupertypes(local.type(supertype));
|
||||
if (!isSpecial.apply(classDescriptor)) {
|
||||
// Special classes (Any, Nothing) have no supertypes
|
||||
for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||
builder.addSupertypes(local.type(supertype));
|
||||
}
|
||||
}
|
||||
|
||||
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.jet.generators.builtins;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -53,7 +55,14 @@ public class BuiltInsSerializer {
|
||||
System.err.println("Could not make directories: " + destDir);
|
||||
}
|
||||
|
||||
final DescriptorSerializer serializer = new DescriptorSerializer(NameTable.Namer.DEFAULT);
|
||||
final DescriptorSerializer serializer = new DescriptorSerializer(NameTable.Namer.DEFAULT, new Predicate<ClassDescriptor>() {
|
||||
private final ImmutableSet<String> set = ImmutableSet.of("Any", "Nothing");
|
||||
|
||||
@Override
|
||||
public boolean apply(ClassDescriptor classDescriptor) {
|
||||
return set.contains(classDescriptor.getName().asString());
|
||||
}
|
||||
});
|
||||
ByteArrayOutputStream classNames = new ByteArrayOutputStream();
|
||||
final DataOutputStream data = new DataOutputStream(classNames);
|
||||
ClassSerializationUtil.serializeClasses(allDescriptors, ClassSerializationUtil.constantSerializer(serializer), new ClassSerializationUtil.Sink() {
|
||||
|
||||
Reference in New Issue
Block a user