Fixed the return type of 'object.__new__' after switching to Typeshed

For a while we will have it specified programmatically in our code
instead of Typeshed since we don't support Type[C] yet.
This commit is contained in:
Andrey Vlasovskikh
2017-02-22 19:37:11 +03:00
parent 5c7fc44672
commit fe61000c67
@@ -159,6 +159,11 @@ public class PyStdlibTypeProvider extends PyTypeProviderBase {
else if ("tuple.__mul__".equals(qname) && callSite instanceof PyBinaryExpression) {
return getTupleMultiplicationResultType((PyBinaryExpression)callSite, context);
}
else if ("object.__new__".equals(qname) && callSite instanceof PyCallExpression) {
final PyExpression firstArgument = ((PyCallExpression)callSite).getArgument(0, PyExpression.class);
final PyClassLikeType classLikeType = as(firstArgument != null ? context.getType(firstArgument) : null, PyClassLikeType.class);
return classLikeType != null ? Ref.create(classLikeType.toInstance()) : null;
}
}
return null;