fixed PY-13884 "Override Methods" loses @staticmethod decorator from parent

This commit is contained in:
Ekaterina Tuzova
2014-09-15 17:12:29 +04:00
parent 1c34eb0a0a
commit c091cfdf37
4 changed files with 25 additions and 2 deletions
@@ -183,8 +183,11 @@ public class PyOverrideImplementUtil {
private static PyFunctionBuilder buildOverriddenFunction(PyClass pyClass, PyFunction baseFunction, boolean implement) {
PyFunctionBuilder pyFunctionBuilder = new PyFunctionBuilder(baseFunction.getName());
final PyDecoratorList decorators = baseFunction.getDecoratorList();
if (decorators != null && decorators.findDecorator(PyNames.CLASSMETHOD) != null) {
pyFunctionBuilder.decorate(PyNames.CLASSMETHOD);
if (decorators != null) {
if (decorators.findDecorator(PyNames.CLASSMETHOD) != null)
pyFunctionBuilder.decorate(PyNames.CLASSMETHOD);
else if (decorators.findDecorator(PyNames.STATICMETHOD) != null)
pyFunctionBuilder.decorate(PyNames.STATICMETHOD);
}
PyAnnotation anno = baseFunction.getAnnotation();
if (anno != null) {
+7
View File
@@ -0,0 +1,7 @@
class A:
@staticmethod
def foo(cls):
cls.k = 3
class B(A):
<caret>pass
@@ -0,0 +1,9 @@
class A:
@staticmethod
def foo(cls):
cls.k = 3
class B(A):
@staticmethod
def foo(cls):
<selection>A.foo(cls)</selection>
@@ -64,6 +64,10 @@ public class PyOverrideTest extends PyTestCase {
doTest();
}
public void testStaticMethod() {
doTest();
}
public void testNewStyle() {
doTest();
}