boolean (@NotNull PyExpression calleeQualifier, @NotNull PyClass cls, @NotNull TypeEvalContext context) { final String prevCalleeName = Optional .of(calleeQualifier) .filter(PyCallExpression.class::isInstance) .map(PyCallExpression.class::cast) .map(PyCallExpression::getCallee) .map(PyExpression::getName) .orElse(null); if (!SUPER.equals(prevCalleeName)) { return false; } final PyExpression[] args = ((PyCallExpression)calleeQualifier).getArguments(); if (args.length == 0) { return true; } final String firstArg = args[0].getText(); final String classQName = cls.getQualifiedName(); if (firstArg.equals(cls.getName()) || firstArg.equals(CANONICAL_SELF + "." + __CLASS__) || classQName != null && classQName.endsWith(firstArg) || firstArg.equals(__CLASS__) && !LanguageLevel.forElement(cls).isPython2()) { return true; } return cls.getAncestorClasses(context) .stream() .map(PyClass::getName) .anyMatch(firstArg::equals); }