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
|
r
|
||||||
+16
-5
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.descriptors.serialization;
|
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.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
|
||||||
@@ -45,18 +47,24 @@ public class DescriptorSerializer {
|
|||||||
};
|
};
|
||||||
private final NameTable nameTable;
|
private final NameTable nameTable;
|
||||||
private final Interner<TypeParameterDescriptor> typeParameters;
|
private final Interner<TypeParameterDescriptor> typeParameters;
|
||||||
|
private final Predicate<ClassDescriptor> isSpecial;
|
||||||
|
|
||||||
public DescriptorSerializer(@NotNull NameTable.Namer namer) {
|
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.nameTable = nameTable;
|
||||||
this.typeParameters = typeParameters;
|
this.typeParameters = typeParameters;
|
||||||
|
this.isSpecial = isSpecial;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DescriptorSerializer createChildSerializer() {
|
private DescriptorSerializer createChildSerializer() {
|
||||||
return new DescriptorSerializer(nameTable, new Interner<TypeParameterDescriptor>(typeParameters));
|
return new DescriptorSerializer(nameTable, new Interner<TypeParameterDescriptor>(typeParameters), Predicates.<ClassDescriptor>alwaysFalse());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -82,8 +90,11 @@ public class DescriptorSerializer {
|
|||||||
builder.addTypeParameters(local.typeParameter(typeParameterDescriptor));
|
builder.addTypeParameters(local.typeParameter(typeParameterDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
if (!isSpecial.apply(classDescriptor)) {
|
||||||
builder.addSupertypes(local.type(supertype));
|
// Special classes (Any, Nothing) have no supertypes
|
||||||
|
for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
|
||||||
|
builder.addSupertypes(local.type(supertype));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package org.jetbrains.jet.generators.builtins;
|
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.Disposable;
|
||||||
import com.intellij.openapi.util.Disposer;
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
@@ -53,7 +55,14 @@ public class BuiltInsSerializer {
|
|||||||
System.err.println("Could not make directories: " + destDir);
|
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();
|
ByteArrayOutputStream classNames = new ByteArrayOutputStream();
|
||||||
final DataOutputStream data = new DataOutputStream(classNames);
|
final DataOutputStream data = new DataOutputStream(classNames);
|
||||||
ClassSerializationUtil.serializeClasses(allDescriptors, ClassSerializationUtil.constantSerializer(serializer), new ClassSerializationUtil.Sink() {
|
ClassSerializationUtil.serializeClasses(allDescriptors, ClassSerializationUtil.constantSerializer(serializer), new ClassSerializationUtil.Sink() {
|
||||||
|
|||||||
Reference in New Issue
Block a user