mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
generate 'return' before super method call in Override Methods if appropriate (PY-1537)
This commit is contained in:
@@ -24,6 +24,7 @@ import com.jetbrains.python.PyNames;
|
||||
import com.jetbrains.python.psi.*;
|
||||
import com.jetbrains.python.psi.impl.PyFunctionBuilder;
|
||||
import com.jetbrains.python.psi.impl.PyPsiUtils;
|
||||
import com.jetbrains.python.psi.types.PyNoneType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -163,6 +164,9 @@ public class PyOverrideImplementUtil {
|
||||
}, ArrayUtil.EMPTY_STRING_ARRAY);
|
||||
int startIndex = 0;
|
||||
|
||||
if (baseFunction.getReturnType() != PyNoneType.INSTANCE) {
|
||||
statementBody.append("return ");
|
||||
}
|
||||
if (baseClass.isNewStyleClass()) {
|
||||
statementBody.append(PyNames.SUPER);
|
||||
statementBody.append("(");
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class A:
|
||||
def doStuff(self, foo=True): return True
|
||||
|
||||
class B(A):
|
||||
def otherMethod(self, foo, bar):
|
||||
print foo, bar
|
||||
@@ -0,0 +1,9 @@
|
||||
class A:
|
||||
def doStuff(self, foo=True): return True
|
||||
|
||||
class B(A):
|
||||
def doStuff(self, foo=True):
|
||||
<selection>return A.doStuff(self, foo)</selection>
|
||||
|
||||
def otherMethod(self, foo, bar):
|
||||
print foo, bar
|
||||
@@ -38,6 +38,10 @@ public class PyOverrideTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testReturnValue() { // PY-1537
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testPy3k() {
|
||||
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON31);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user