Common logic extracted from lazy type implementations

This commit is contained in:
Andrey Breslav
2013-09-27 18:18:08 -07:00
parent 8bfa6f3aeb
commit 51d54661a1
4 changed files with 70 additions and 88 deletions
@@ -28,7 +28,6 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
import org.jetbrains.jet.storage.MemoizedFunctionToNullable;
import org.jetbrains.jet.storage.NotNullLazyValue;
import org.jetbrains.jet.storage.StorageManager;
@@ -198,7 +197,7 @@ public class TypeDeserializer {
return debugName;
}
private class DeserializedType implements JetType {
private class DeserializedType extends AbstractJetType {
private final ProtoBuf.Type typeProto;
private final NotNullLazyValue<TypeConstructor> constructor;
private final List<TypeProjection> arguments;
@@ -265,28 +264,5 @@ public class TypeDeserializer {
public List<AnnotationDescriptor> getAnnotations() {
return Collections.emptyList();
}
@Override
public String toString() {
return TypeUtils.toString(this);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof JetType)) return false;
JetType type = (JetType) o;
return isNullable() == type.isNullable() && JetTypeChecker.INSTANCE.equalTypes(this, type);
}
@Override
public int hashCode() {
int result = getConstructor().hashCode();
result = 31 * result + getArguments().hashCode();
result = 31 * result + (isNullable() ? 1 : 0);
return result;
}
}
}