extract method object: process exit statements as they may contain refs to outer vars (IDEA-96772); disable duplicate extraction

This commit is contained in:
anna
2012-12-06 17:54:16 +01:00
parent 55d264c176
commit fabf91af4d
5 changed files with 89 additions and 3 deletions
@@ -0,0 +1,14 @@
class A {
boolean foo() {
<selection>for (int i = 0; i < 9; i++) {
final Boolean foo = Boolean.FALSE;
if (foo != null) {
return foo;
}
}</selection>
return false;
}
}
@@ -0,0 +1,35 @@
class A {
boolean foo() {
Inner inner = new Inner().invoke();
if (inner.is()) return inner.getFoo();
return false;
}
private class Inner {
private boolean myResult;
private Boolean foo;
boolean is() {
return myResult;
}
public Boolean getFoo() {
return foo;
}
public Inner invoke() {
for (int i = 0; i < 9; i++) {
foo = Boolean.FALSE;
if (foo != null) {
myResult = true;
return this;
}
}
myResult = false;
return this;
}
}
}