return weak type of class as return type of constructor call if the actual return type of __new__ is unknown (PY-6671)

This commit is contained in:
Dmitry Jemerov
2012-08-07 16:24:03 +02:00
parent e735ebc7ef
commit bb59f0adb3
4 changed files with 32 additions and 0 deletions
@@ -162,6 +162,12 @@ public class PyCallExpressionImpl extends PyElementImpl implements PyCallExpress
}
}
if (t != null && !(t instanceof PyNoneType)) {
if (t instanceof PyTypeReference) {
PyType resolved = ((PyTypeReference)t).resolve(callee, context);
if (resolved == null) {
return new PyWeakClassType(cls, false);
}
}
return t;
}
}
@@ -0,0 +1,11 @@
def foo(): return foo()
class Template(object):
def __new__(cls):
return foo()
def xyzzy(self):
pass
t = Template()
t.xyzzy()
@@ -0,0 +1,11 @@
def foo(): return foo()
class Template(object):
def __new__(cls):
return foo()
def xyzzy(self):
pass
t = Template()
t.x<caret>
@@ -584,4 +584,8 @@ public class PythonCompletionTest extends PyTestCase {
public void testNoInitForSubmodules() {
doMultiFileTest();
}
public void testUnknownNewReturnType() { // PY-6671
doTest();
}
}