Merge branch 'master' into vlan/pyi
authorAndrey Vlasovskikh <andrey.vlasovskikh@jetbrains.com>
Tue, 18 Aug 2015 19:09:34 +0000 (22:09 +0300)
committerAndrey Vlasovskikh <andrey.vlasovskikh@jetbrains.com>
Tue, 18 Aug 2015 19:09:34 +0000 (22:09 +0300)
Conflicts:
python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java

1  2 
python/src/com/jetbrains/python/psi/impl/PyCallExpressionHelper.java
python/src/com/jetbrains/python/psi/impl/PyFunctionImpl.java
python/src/com/jetbrains/python/psi/types/PyTypeChecker.java

index aeefc3902b1914bd4062677c38619d84d2199322,9588a385d2fd4a53d60661f09221499c96e80acb..f87e0bd99e7bbdc854362f7013de8bfed228ad6a
@@@ -72,27 -70,25 +72,27 @@@ public class PyCallExpressionHelper 
    public static Pair<String, PyFunction> interpretAsModifierWrappingCall(PyCallExpression redefiningCall, PsiElement us) {
      PyExpression redefining_callee = redefiningCall.getCallee();
      if (redefiningCall.isCalleeText(PyNames.CLASSMETHOD, PyNames.STATICMETHOD)) {
 -      final PyReferenceExpression refex = (PyReferenceExpression)redefining_callee;
 -      final String refname = refex.getReferencedName();
 -      if ((PyNames.CLASSMETHOD.equals(refname) || PyNames.STATICMETHOD.equals(refname))) {
 -        PsiElement redefining_func = refex.getReference().resolve();
 -        if (redefining_func != null) {
 -          PsiElement true_func = PyBuiltinCache.getInstance(us).getByName(refname);
 -          if (true_func instanceof PyClass) true_func = ((PyClass)true_func).findInitOrNew(true, null);
 -          if (true_func == redefining_func) {
 -            // yes, really a case of "foo = classmethod(foo)"
 -            PyArgumentList arglist = redefiningCall.getArgumentList();
 -            if (arglist != null) { // really can't be any other way
 -              PyExpression[] args = arglist.getArguments();
 -              if (args.length == 1) {
 -                PyExpression possible_original_ref = args[0];
 -                if (possible_original_ref instanceof PyReferenceExpression) {
 -                  PsiElement original = ((PyReferenceExpression)possible_original_ref).getReference().resolve();
 -                  if (original instanceof PyFunction) {
 -                    // pinned down the original; replace our resolved callee with it and add flags.
 -                    return Pair.create(refname, (PyFunction)original);
 +      final PyReferenceExpression referenceExpr = (PyReferenceExpression)redefining_callee;
 +      if (referenceExpr != null) {
 +        final String refName = referenceExpr.getReferencedName();
 +        if ((PyNames.CLASSMETHOD.equals(refName) || PyNames.STATICMETHOD.equals(refName))) {
 +          PsiElement redefining_func = referenceExpr.getReference().resolve();
 +          if (redefining_func != null) {
 +            PsiElement true_func = PyBuiltinCache.getInstance(us).getByName(refName);
-             if (true_func instanceof PyClass) true_func = ((PyClass)true_func).findInitOrNew(true);
++            if (true_func instanceof PyClass) true_func = ((PyClass)true_func).findInitOrNew(true, null);
 +            if (true_func == redefining_func) {
 +              // yes, really a case of "foo = classmethod(foo)"
 +              PyArgumentList argumentList = redefiningCall.getArgumentList();
 +              if (argumentList != null) { // really can't be any other way
 +                PyExpression[] args = argumentList.getArguments();
 +                if (args.length == 1) {
 +                  PyExpression possible_original_ref = args[0];
 +                  if (possible_original_ref instanceof PyReferenceExpression) {
 +                    PsiElement original = ((PyReferenceExpression)possible_original_ref).getReference().resolve();
 +                    if (original instanceof PyFunction) {
 +                      // pinned down the original; replace our resolved callee with it and add flags.
 +                      return Pair.create(refName, (PyFunction)original);
 +                    }
                    }
                  }
                }