Do not compare local classes by FqNames
This commit is contained in:
@@ -101,6 +101,20 @@ public class DescriptorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* descriptor may be local itself or have a local ancestor
|
||||
*/
|
||||
public static boolean isLocal(@NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationDescriptor current = descriptor;
|
||||
while (current instanceof MemberDescriptor) {
|
||||
if (isAnonymousObject(current) || ((DeclarationDescriptorWithVisibility) current).getVisibility() == Visibilities.LOCAL) {
|
||||
return true;
|
||||
}
|
||||
current = current.getContainingDeclaration();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static FqNameUnsafe getFqName(@NotNull DeclarationDescriptor descriptor) {
|
||||
FqName safe = getFqNameSafeIfPossible(descriptor);
|
||||
|
||||
@@ -41,8 +41,8 @@ public abstract class AbstractClassTypeConstructor implements TypeConstructor {
|
||||
ClassifierDescriptor otherDescriptor = ((TypeConstructor) other).getDeclarationDescriptor();
|
||||
|
||||
// All error types have the same descriptor
|
||||
if (myDescriptor != null && ErrorUtils.isError(myDescriptor)
|
||||
|| otherDescriptor != null && ErrorUtils.isError(otherDescriptor)) {
|
||||
if (myDescriptor != null && !hasMeaningfulFqName(myDescriptor) ||
|
||||
otherDescriptor != null && !hasMeaningfulFqName(otherDescriptor)) {
|
||||
return me == other;
|
||||
}
|
||||
|
||||
@@ -65,4 +65,9 @@ public abstract class AbstractClassTypeConstructor implements TypeConstructor {
|
||||
}
|
||||
return System.identityHashCode(me);
|
||||
}
|
||||
|
||||
private static boolean hasMeaningfulFqName(@NotNull ClassifierDescriptor descriptor) {
|
||||
return !ErrorUtils.isError(descriptor) &&
|
||||
!DescriptorUtils.isLocal(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user