IDEA-151867 ExtractMethodObject drops declaration of local variable when it is shared with a return value

This commit is contained in:
Egor.Ushakov
2016-02-25 20:47:12 +03:00
parent 18ea3ac04b
commit 4caabe011d
4 changed files with 64 additions and 1 deletions
@@ -0,0 +1,10 @@
class Test {
public int context1() {
<selection>int i, j;
i = 0;
j = 1;
if (j > 0) return i;
</selection>
return 0;
}
}
@@ -0,0 +1,33 @@
class Test {
public int context1() {
Inner inner = new Inner().invoke();
if (inner.is()) return inner.getI();
return 0;
}
private class Inner {
private boolean myResult;
private int i;
boolean is() {
return myResult;
}
public int getI() {
return i;
}
public Inner invoke() {
int j;
i = 0;
j = 1;
if (j > 0) {
myResult = true;
return this;
}
myResult = false;
return this;
}
}
}