diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java index 508be0e302e..f6a75b7ecbb 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/AbstractClassTypeConstructor.java @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.types; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.name.FqNameUnsafe; import org.jetbrains.kotlin.resolve.DescriptorUtils; import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt; import org.jetbrains.kotlin.storage.StorageManager; @@ -62,6 +61,7 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct @Override public final boolean equals(Object other) { + if (this == other) return true; if (!(other instanceof TypeConstructor)) return false; // performance optimization: getFqName is slow method @@ -74,13 +74,11 @@ public abstract class AbstractClassTypeConstructor extends AbstractTypeConstruct ClassifierDescriptor myDescriptor = getDeclarationDescriptor(); ClassifierDescriptor otherDescriptor = ((TypeConstructor) other).getDeclarationDescriptor(); - // descriptor for type is created once per module - if (myDescriptor == otherDescriptor) return true; - - // All error types have the same descriptor if (!hasMeaningfulFqName(myDescriptor) || otherDescriptor != null && !hasMeaningfulFqName(otherDescriptor)) { - return this == other; + // All error types and local classes have the same descriptor, + // but we've already checked identity equality in the beginning of the method + return false; } if (myDescriptor instanceof ClassDescriptor && otherDescriptor instanceof ClassDescriptor) {