mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
If we cannot infer the type of '__new__', return a weak class type (PY-10893)
This commit is contained in:
@@ -408,6 +408,12 @@ public class PyCallExpressionHelper {
|
||||
if (t != null && !(t instanceof PyNoneType)) {
|
||||
return t;
|
||||
}
|
||||
if (cls != null && t == null) {
|
||||
final PyFunction newMethod = cls.findMethodByName(PyNames.NEW, true);
|
||||
if (newMethod != null && !PyBuiltinCache.getInstance(call).hasInBuiltins(newMethod)) {
|
||||
return PyUnionType.createWeakType(new PyClassTypeImpl(cls, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cls != null) {
|
||||
return new PyClassTypeImpl(cls, false);
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
from b import C
|
||||
|
||||
c = C()
|
||||
c.foo()
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class C(object):
|
||||
def __new__(cls):
|
||||
return D()
|
||||
|
||||
|
||||
class D(object):
|
||||
def foo(self):
|
||||
pass
|
||||
+5
@@ -298,6 +298,11 @@ public class PyUnresolvedReferencesInspectionTest extends PyTestCase {
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
// PY-10893
|
||||
public void testCustomNewReturnInAnotherModule() {
|
||||
doMultiFileTest("a.py");
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile(TEST_DIRECTORY + getTestName(true) + ".py");
|
||||
myFixture.enableInspections(PyUnresolvedReferencesInspection.class);
|
||||
|
||||
Reference in New Issue
Block a user