Error types should not be compared by FqName

This commit is contained in:
Andrey Breslav
2014-05-19 13:30:41 +04:00
parent a66f44e4f5
commit bee4dbc672
@@ -36,9 +36,16 @@ public abstract class AbstractClassTypeConstructor implements TypeConstructor {
public static boolean equals(@NotNull TypeConstructor me, Object other) {
if (!(other instanceof TypeConstructor)) return false;
ClassifierDescriptor myDescriptor = me.getDeclarationDescriptor();
ClassifierDescriptor otherDescriptor = ((TypeConstructor) other).getDeclarationDescriptor();
// All error types have the same descriptor
if (myDescriptor != null && ErrorUtils.isError(myDescriptor)
|| otherDescriptor != null && ErrorUtils.isError(otherDescriptor)) {
return me == other;
}
if (myDescriptor == otherDescriptor) return true;
if (myDescriptor instanceof ClassDescriptor && otherDescriptor instanceof ClassDescriptor) {
@@ -51,8 +58,9 @@ public abstract class AbstractClassTypeConstructor implements TypeConstructor {
}
public static int hashCode(@NotNull TypeConstructor me) {
if (me.getDeclarationDescriptor() instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) me.getDeclarationDescriptor();
ClassifierDescriptor descriptor = me.getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor && !ErrorUtils.isError(descriptor)) {
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
return DescriptorUtils.getFqName(classDescriptor).hashCode();
}
return System.identityHashCode(me);