inline parameter: safely inline recursive calls (IDEA-55529)

This commit is contained in:
anna
2010-07-27 19:23:53 +04:00
parent 168d489e88
commit 5897738dfc
5 changed files with 74 additions and 2 deletions
@@ -0,0 +1,18 @@
import java.lang.Integer;
import java.util.*;
import java.util.ArrayList;
public class ExpData {
private final List<Integer> myResult = new ArrayList<Integer>();
{
m(10, myResult);
}
private void m(int i, List<Integer> re<caret>sult) {
if (i > 0) {
m(i - 1, result);
}
result.add(i);
m(2, new ArrayList<Integer>());
}
}
@@ -0,0 +1,15 @@
import java.util.*;
public class ExpData {
private final List<Integer> myResult = new ArrayList<Integer>();
{
m(10, myResult);
}
private void m(int i, List<Integer> re<caret>sult) {
if (i > 0) {
m(i - 1, result);
}
result.add(i);
}
}
@@ -0,0 +1,15 @@
import java.util.*;
public class ExpData {
private final List<Integer> myResult = new ArrayList<Integer>();
{
m(10);
}
private void m(int i) {
if (i > 0) {
m(i - 1);
}
myResult.add(i);
}
}
@@ -250,6 +250,21 @@ public class InlineParameterTest extends LightCodeInsightTestCase {
doTest(false);
}
public void testInlineRecursive() throws Exception {
doTest(false);
}
public void testCantInlineRecursive() throws Exception {
try {
doTest(false);
}
catch (CommonRefactoringUtil.RefactoringErrorHintException e) {
assertEquals("Cannot find constant initializer for parameter", e.getMessage());
return;
}
fail("Initializer shoul not be found");
}
public void testParameterDefWithWriteAccess() throws Exception {
try {
doTest(false);