mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: better check that parameter is still available after inlining (IDEA-308977)
GitOrigin-RevId: 4c9da5c574ed55e63dfef43d0d5dd655931533ee
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f959b2e066
commit
e6233a181d
+1
@@ -349,6 +349,7 @@ public class InlineParameterExpressionProcessor extends BaseRefactoringProcessor
|
||||
} else if (element instanceof PsiParameter param && PsiTreeUtil.isAncestor(param.getDeclarationScope(), myInitializer, true)) {
|
||||
boolean bound = false;
|
||||
for (PsiParameter parameter : myMethod.getParameterList().getParameters()) {
|
||||
if (parameter == myParameter) continue;
|
||||
if (parameter.getType().equals(param.getType()) && parameter.getName().equals(param.getName())) {
|
||||
bound = true;
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.lang.Integer;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Aphrodite {
|
||||
|
||||
public void recursiveCountdown(Integer a<caret>){
|
||||
if (a == 1){
|
||||
return;
|
||||
}
|
||||
recursiveCountdown(a-1);
|
||||
}
|
||||
}
|
||||
@@ -302,6 +302,15 @@ public class InlineParameterTest extends LightRefactoringTestCase {
|
||||
assertEquals("Cannot find constant initializer for parameter", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testCantInlineRecursive2() {
|
||||
try {
|
||||
doTest(false);
|
||||
}
|
||||
catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
|
||||
assertEquals("Parameter initializer depends on caller's parameter <b><code>a</code></b>", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testParameterDefWithWriteAccess() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user