mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed unresolved reference in list comprehension inside default value of parameter (PY-7516)
This commit is contained in:
@@ -177,6 +177,17 @@ public class ScopeImpl implements Scope {
|
||||
super.visitPyNonlocalStatement(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyFunction(PyFunction node) {
|
||||
for (PyParameter parameter : node.getParameterList().getParameters()) {
|
||||
final PyExpression defaultValue = parameter.getDefaultValue();
|
||||
if (defaultValue != null) {
|
||||
defaultValue.accept(this);
|
||||
}
|
||||
}
|
||||
super.visitPyFunction(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitPyElement(PyElement node) {
|
||||
if (node instanceof PsiNamedElement && !(node instanceof PyKeywordArgument)) {
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
def f(x=[i for i in [1, 2, 3]]): # i is resolved in file scope to i
|
||||
return x
|
||||
+5
@@ -221,6 +221,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
});
|
||||
}
|
||||
|
||||
// PY-7516
|
||||
public void testComprehensionInParameterValue() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user