PY-28562: Add implicit object super when class has new style metaclass

This commit is contained in:
fitermay
2018-03-01 15:06:00 +03:00
committed by Andrey Vlasovskikh
parent 910854f617
commit 5be8da029a
3 changed files with 20 additions and 1 deletions
@@ -1420,7 +1420,7 @@ public class PyClassImpl extends PyBaseElementImpl<PyClassStub> implements PyCla
return null;
}
if (LanguageLevel.forElement(this).isPython2() && getMetaClassQName() == null) {
if (LanguageLevel.forElement(this).isPython2() && getMetaClassQName() == null && !hasNewStyleMetaClass(this)) {
final QualifiedName typesInstanceTypeQName = QualifiedName.fromDottedString(PyNames.TYPES_INSTANCE_TYPE);
final PsiElement typesInstanceType = resolveTopLevelMember(typesInstanceTypeQName, fromFoothold(this));
@@ -0,0 +1,13 @@
__metaclass__ = type
class A:
def foo(self):
print "foo"
class B(A):
def foo(self):
super(B, self).foo()
B().__getattribute__
# <ref>
@@ -376,6 +376,12 @@ public class PyResolveTest extends PyResolveTestCase {
assertResolvesTo(PyFunction.class, "foo");
}
//PY-28562
public void testSuperMetaClassInheritsObject() {
assertResolvesTo(PyFunction.class, "__getattribute__");
}
public void testSuperDunderClass() { // PY-1190
assertResolvesTo(PyFunction.class, "foo");
}