mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed bug in scoping rules for references in default function argument values (PY-3550)
This commit is contained in:
@@ -46,8 +46,14 @@ public class ScopeUtil {
|
||||
@Nullable
|
||||
public static ScopeOwner getDeclarationScopeOwner(PyReferenceExpression node) {
|
||||
final String name = node.getName();
|
||||
PsiElement element = node;
|
||||
if (name != null) {
|
||||
ScopeOwner owner = PsiTreeUtil.getParentOfType(node, ScopeOwner.class);
|
||||
// References in default values of parameters are defined somewhere in outer scopes
|
||||
if (PsiTreeUtil.getParentOfType(node, PyParameter.class) != null) {
|
||||
element = PsiTreeUtil.getParentOfType(node, ScopeOwner.class);
|
||||
}
|
||||
|
||||
ScopeOwner owner = PsiTreeUtil.getParentOfType(element, ScopeOwner.class);
|
||||
while (owner != null) {
|
||||
Scope scope = ControlFlowCache.getScope(owner);
|
||||
if (scope.containsDeclaration(name)) {
|
||||
|
||||
Reference in New Issue
Block a user