mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 08:51:02 +07:00
PY-36205 False unresolved attribute reference for enum value when enum inherits str or StrEnum
(cherry picked from commit 132c996908988bccc59035c033c21325c48a6016) GitOrigin-RevId: 8a968f2c4b2bac5c77ca60b1e22b78afc77b1eef
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1f72432cd7
commit
3db29fcbc8
@@ -417,14 +417,23 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl<PyTargetExpression
|
||||
@Nullable
|
||||
private static PyFunction findMethodByName(@NotNull PyType type, @NotNull String name, @NotNull TypeEvalContext context) {
|
||||
final PyResolveContext resolveContext = PyResolveContext.defaultContext(context);
|
||||
final List<? extends RatedResolveResult> results = type.resolveMember(name, null, AccessDirection.READ, resolveContext);
|
||||
final PyType actualType;
|
||||
if (type instanceof PyClassType classType && classType.isDefinition()) {
|
||||
PyClassLikeType metaclassType = classType.getMetaClassType(resolveContext.getTypeEvalContext(), true);
|
||||
if (metaclassType == null) return null;
|
||||
actualType = metaclassType;
|
||||
}
|
||||
else {
|
||||
actualType = type;
|
||||
}
|
||||
final List<? extends RatedResolveResult> results = actualType.resolveMember(name, null, AccessDirection.READ, resolveContext);
|
||||
if (results != null) {
|
||||
List<PyFunction> allMethods = StreamEx.of(results)
|
||||
.map(RatedResolveResult::getElement)
|
||||
.select(PyFunction.class)
|
||||
.toList();
|
||||
// TODO Migrate this ad-hoc logic to the normal process of resolving overloads in PyCallExpressionHelper
|
||||
PyFunction matchingBySelf = ContainerUtil.find(allMethods, method -> selfParameterMatchesReceiver(method, type, context));
|
||||
PyFunction matchingBySelf = ContainerUtil.find(allMethods, method -> selfParameterMatchesReceiver(method, actualType, context));
|
||||
return matchingBySelf != null ? matchingBySelf : ContainerUtil.getFirstItem(allMethods);
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user