summaryrefslogtreecommitdiff
path: root/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java')
-rw-r--r--python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java
index 838a4dbcc75a..f207169df77f 100644
--- a/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java
+++ b/python/src/com/jetbrains/python/psi/resolve/PyResolveUtil.java
@@ -101,7 +101,13 @@ public class PyResolveUtil {
@Nullable PsiElement roof) {
// Use real context here to enable correct completion and resolve in case of PyExpressionCodeFragment!!!
final PsiElement realContext = PyPsiUtils.getRealContext(element);
- final ScopeOwner originalOwner = ScopeUtil.getScopeOwner(realContext);
+ final ScopeOwner originalOwner;
+ if (realContext != element && realContext instanceof PyFile) {
+ originalOwner = (PyFile)realContext;
+ }
+ else {
+ originalOwner = ScopeUtil.getScopeOwner(realContext);
+ }
final PsiElement parent = element.getParent();
final boolean isGlobalOrNonlocal = parent instanceof PyGlobalStatement || parent instanceof PyNonlocalStatement;
ScopeOwner owner = originalOwner;