invoke scanOuterContext() also for lambdas (PY-2182)

This commit is contained in:
Dmitry Jemerov
2010-10-27 18:38:07 +04:00
parent 0fa152aea3
commit e7b62855ed
3 changed files with 12 additions and 2 deletions

View File

@@ -162,7 +162,7 @@ public class PyResolveUtil {
// if we're under a cap, an external object that we want to use might be also defined below us.
// look through all contexts, closest first.
PsiElement ret = null;
PsiElement our_cap = PsiTreeUtil.getParentOfType(start, PyFunction.class);
PsiElement our_cap = PsiTreeUtil.getParentOfType(start, Callable.class);
if (our_cap != null) {
PsiElement cap = our_cap;
while (true) {

View File

@@ -0,0 +1,6 @@
class TestOne():
x = lambda self: TestTwo()
# <ref>
class TestTwo():
pass

View File

@@ -48,7 +48,7 @@ public class PyResolveTest extends PyResolveTestCase {
public void testToConstructorInherited() {
ResolveResult[] targets = multiResolve();
assertEquals(targets.length, 2); // to class, to init
assertEquals(2, targets.length); // to class, to init
PsiElement elt;
// class
elt = targets[0].getElement();
@@ -366,4 +366,8 @@ public class PyResolveTest extends PyResolveTestCase {
final PyFunction pyFunction = assertResolvesTo(PyFunction.class, "eval");
assertEquals("__builtin__.py", pyFunction.getContainingFile().getName());
}
public void testLambdaToClass() { // PY-2182
assertResolvesTo(PyClass.class, "TestTwo");
}
}