Fixed wrong resolve to submodule instead of function with the same name (PY-6866)

This commit is contained in:
Andrey Vlasovskikh
2012-07-03 19:07:11 +04:00
parent 65388e21b4
commit 4140c25a7b
5 changed files with 12 additions and 1 deletions
@@ -91,7 +91,7 @@ public class PyFileImpl extends PsiFileBase implements PyFile, PyExpression {
}
if (PyNames.INIT_DOT_PY.equals(getName())) {
final PyQualifiedName qName = fromImportStatement.getImportSourceQName();
if (qName != null) {
if (qName != null && !localDeclarations.containsKey(qName.toString())) {
localDeclarations.put(qName.getLastComponent(), fromImportStatement);
}
}
@@ -0,0 +1 @@
from m1 import m1
@@ -0,0 +1,2 @@
def m1():
pass
@@ -381,6 +381,11 @@ public class PyMultiFileResolveTest extends PyResolveTestCase {
assertResolvesTo(PyFile.class, "m2.py");
}
// PY-6866
public void testFunctionAndSubmoduleNamedIdentically() {
assertResolvesTo(PyFunction.class, "m1");
}
private void prepareTestDirectory() {
final String testName = getTestName(true);
myFixture.copyDirectoryToProject(testName, "");