diff --git a/python/src/com/jetbrains/python/inspections/PyMissingConstructorInspection.java b/python/src/com/jetbrains/python/inspections/PyMissingConstructorInspection.java index a70a2a5dcaff..34f6d2ba6c61 100644 --- a/python/src/com/jetbrains/python/inspections/PyMissingConstructorInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyMissingConstructorInspection.java @@ -47,7 +47,8 @@ public class PyMissingConstructorInspection extends PyInspection { if (node.isNewStyleClass()) superNames.push(PyNames.SUPER); - addSuperNames(superNames, superClasses, name); + Iterable ansectors = node.iterateAncestors(); + addSuperNames(superNames, ansectors); if (!superHasConstructor(node)) return; PyFunction initMethod = node.findMethodByName(PyNames.INIT, false); @@ -78,18 +79,16 @@ public class PyMissingConstructorInspection extends PyInspection { } } - private static void addSuperNames(Stack st, PsiElement[] superClasses, String name) { - for (PsiElement cl : superClasses) { - if (!name.equals(cl.getText())) { - if (!PyNames.OBJECT.equals(cl.getText())) - st.push(cl.getText()); + private static void addSuperNames(Stack st, Iterable superClasses) { + for (PyClassRef cl : superClasses) { + if (!PyNames.OBJECT.equals(cl.getClassName())) + st.push(cl.getClassName()); - if (cl instanceof PyReferenceExpression) { - PyReferenceExpression ref = (PyReferenceExpression) cl; - final PsiElement result = ref.getReference(PyResolveContext.noProperties()).resolve(); - if (result instanceof PyClass) - addSuperNames(st, ((PyClass)result).getSuperClassExpressions(), name); - } + if (cl instanceof PyReferenceExpression) { + PyReferenceExpression ref = (PyReferenceExpression) cl; + final PsiElement result = ref.getReference(PyResolveContext.noProperties()).resolve(); + if (result instanceof PyClass) + addSuperNames(st, ((PyClass)result).iterateAncestors()); } } } diff --git a/python/testData/inspections/PyMissingConstructorInspection/test.py b/python/testData/inspections/PyMissingConstructorInspection/test.py index 2aee1177cadf..c8036c8818ee 100644 --- a/python/testData/inspections/PyMissingConstructorInspection/test.py +++ b/python/testData/inspections/PyMissingConstructorInspection/test.py @@ -62,4 +62,9 @@ class B(A): class C(B): def __init__(self): - print ("Constructor C was called") \ No newline at end of file + print ("Constructor C was called") + +#PY-3395 +class Over(Over): + def __init__(self): + pass \ No newline at end of file