From a95bbb0f1d8f0f9633f4b21f60efd9f3d99c49ef Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 4 Jun 2013 22:41:24 +0400 Subject: [PATCH] equals() and hashCode() for lazy types in built-ins --- .../serialization/TypeDeserializer.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java index d46ddfd9fcc..2ded0c5263b 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java @@ -25,6 +25,7 @@ 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 java.util.ArrayList; import java.util.Collections; @@ -120,6 +121,24 @@ public class TypeDeserializer { 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 = constructor != null ? constructor.hashCode() : 0; + result = 31 * result + arguments.hashCode(); + result = 31 * result + (isNullable() ? 1 : 0); + return result; + } }; }