mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
inline parameter: safely inline recursive calls (IDEA-55529)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user