Fixed callable inspection for 'namedtuple' instances (PY-8801)

Don't cast reference type returned by a type provider to an instance
type. It should know better what type to return.
This commit is contained in:
Andrey Vlasovskikh
2013-02-12 21:27:01 +04:00
parent 9031552f27
commit 8603259282
3 changed files with 9 additions and 3 deletions
@@ -420,9 +420,6 @@ public class PyCallExpressionHelper {
}
final PyType providedType = PyReferenceExpressionImpl.getReferenceTypeFromProviders(target, context, call);
if (providedType != null) {
if (providedType instanceof PyClassType) {
return ((PyClassType)providedType).toInstance();
}
return providedType;
}
if (target instanceof Callable) {
@@ -0,0 +1,4 @@
import collections
Point = collections.namedtuple('Point', 'x y')
p1 = Point(1, 2)
@@ -69,6 +69,11 @@ public class PyCallingNonCallableInspectionTest extends PyTestCase {
doTest();
}
// PY-8801
public void testQualifiedNamedTuple() {
doTest();
}
private void doTest() {
setLanguageLevel(LanguageLevel.PYTHON27);
try {