mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix resolving global variable reassignment
GitOrigin-RevId: 235f566771e9bd83c5b04e47c170501830b5c66a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3cb186667e
commit
77b461420d
@@ -136,7 +136,7 @@ public class ScopeImpl implements Scope {
|
||||
if (myNamedElements == null || myImportedNameDefiners == null) {
|
||||
collectDeclarations();
|
||||
}
|
||||
if (isNonlocal(name)) {
|
||||
if (isNonlocal(name) || isGlobal(name)) {
|
||||
return false;
|
||||
}
|
||||
if (!getNamedElements(name, true).isEmpty()) {
|
||||
|
||||
@@ -270,7 +270,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
|
||||
final ScopeOwner resolvedOwner = processor.getOwner();
|
||||
|
||||
final Collection<PsiElement> resolvedElements = processor.getElements();
|
||||
if (resolvedOwner != null && !resolvedElements.isEmpty() && !ControlFlowCache.getScope(resolvedOwner).isGlobal(referencedName)) {
|
||||
if (resolvedOwner != null && !resolvedElements.isEmpty()) {
|
||||
if (resolvedOwner == referenceOwner) {
|
||||
final List<Instruction> instructions = getLatestDefinitions(referencedName, resolvedOwner, realContext);
|
||||
// TODO: Use the results from the processor as a cache for resolving to latest defs
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
def f():
|
||||
global xx
|
||||
xx = 2
|
||||
# <ref>
|
||||
@@ -754,11 +754,15 @@ public class PyResolveTest extends PyResolveTestCase {
|
||||
assertEquals("2", target.getText());
|
||||
}
|
||||
|
||||
|
||||
public void testGlobalNotDefinedAtTopLevel() {
|
||||
assertResolvesTo(PyTargetExpression.class, "foo");
|
||||
}
|
||||
|
||||
public void testGlobalReassignmentNotDefinedAtTopLevel() {
|
||||
final PyTargetExpression target = assertResolvesTo(PyTargetExpression.class, "xx");
|
||||
assertInstanceOf(target.getParent(), PyGlobalStatement.class);
|
||||
}
|
||||
|
||||
// PY-13734
|
||||
public void testImplicitDunderClass() {
|
||||
assertUnresolved();
|
||||
|
||||
Reference in New Issue
Block a user