Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2012-08-09 14:16:25 +02:00
3 changed files with 28 additions and 9 deletions
@@ -66,9 +66,12 @@ public class PyParameterListImpl extends PyBaseElementImpl<PyParameterListStub>
public boolean isCompatibleTo(@NotNull PyParameterList other) {
PyParameter[] params = getParameters();
final PyParameter[] otherParams = other.getParameters();
final int optionalCount = optionalParametersCount(params);
final int otherOptionalCount = optionalParametersCount(otherParams);
final int requiredCount = params.length - optionalCount;
final int otherRequiredCount = otherParams.length - otherOptionalCount;
if (hasPositionalContainer() || hasKeywordContainer()) {
// TODO: Check required arguments count of the current parameters list
return true;
return requiredCount <= otherRequiredCount;
}
final PyFunction otherFunction = other.getContainingFunction();
final boolean otherHasArgs = other.hasPositionalContainer();
@@ -86,11 +89,7 @@ public class PyParameterListImpl extends PyBaseElementImpl<PyParameterListStub>
}
return otherParams.length == specialParamsCount;
}
final int optionalCount = optionalParametersCount(params);
final int otherOptionalCount = optionalParametersCount(otherParams);
final int requiredCount = params.length - optionalCount;
final int otherRequiredCount = otherParams.length - otherOptionalCount;
return requiredCount <= otherRequiredCount && params.length >= otherRequiredCount && optionalCount >= otherOptionalCount;
return requiredCount <= otherRequiredCount && params.length >= otherParams.length && optionalCount >= otherOptionalCount;
}
private static int optionalParametersCount(@NotNull PyParameter[] parameters) {
@@ -1,6 +1,6 @@
package com.jetbrains.python.refactoring.introduce.constant;
import com.intellij.openapi.util.text.StringUtilRt;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.util.containers.HashSet;
@@ -45,7 +45,7 @@ public class PyIntroduceConstantHandler extends IntroduceHandler {
protected Collection<String> generateSuggestedNames(@NotNull final PyExpression expression) {
Collection<String> names = new HashSet<String>();
for (String name : super.generateSuggestedNames(expression)) {
names.add(StringUtilRt.toUpperCase(name));
names.add(StringUtil.toUpperCase(name));
}
return names;
}
@@ -113,3 +113,23 @@ class c24:
class c25(c24):
def foo(self, arg1, arg2=None): #pass
pass
# PY-7162
class c26:
def foo(self, arg1, arg2=None):
pass
class c27(c26):
def foo<warning descr="Method signature does not match signature of base method">(self, arg1=None)</warning>: #fail
pass
# PY-7159
class c28:
def foo(self):
pass
class c29(c28):
def foo<warning descr="Method signature does not match signature of base method">(self, p1, **kwargs)</warning>: #fail
pass