[python] fix a bug with obtaining ancestor classes in com.jetbrains.python.psi.impl.PyClassImpl.mroLinearize

Fix a bug with a situation when two identical inctances of type `Generic` were stored in the map in `com.jetbrains.python.psi.impl.PyClassImpl.mroLinearize` and were processed separately due to not matching hashcodes and equals methods. This situation caused an `MROException` to be thrown so the class ancestors could not be defined properly. It affected generic types matching as an actually generic class was not recognized as generic because of the wrong list of ancestors.

GitOrigin-RevId: 391390c5143b0c7247bd55f148d519f80063d5a8
This commit is contained in:
Daniil Kalinin
2024-09-04 10:57:28 +00:00
committed by intellij-monorepo-bot
parent 681e3a7d58
commit 8c01fbbebd
@@ -252,6 +252,21 @@ public final class PyCustomType implements PyClassLikeType {
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PyCustomType type)) return false;
return myInstanceType == type.myInstanceType &&
myTypesToMimicAsSuperTypes == type.myTypesToMimicAsSuperTypes &&
Objects.equals(myTypesToMimic, type.myTypesToMimic) &&
Objects.equals(myQualifiedName, type.myQualifiedName);
}
@Override
public int hashCode() {
return Objects.hash(myInstanceType, myTypesToMimicAsSuperTypes, myQualifiedName, myTypesToMimic);
}
/**
* Predicate that filters resolve candidates using {@link #myFilter}