mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
change signature from usage: ignore types of poly expressions if they are not assignable (IDEA-156521)
This commit is contained in:
@@ -38,6 +38,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.SuggestedNameInfo;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.impl.source.resolve.graphInference.PsiPolyExpressionUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
@@ -318,6 +319,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
buf.append(presentableText);
|
||||
}
|
||||
else {
|
||||
if (PsiPolyExpressionUtil.isPolyExpression(expression)) return null;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return null;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
@@ -391,6 +393,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
}
|
||||
else if (expression != null) {
|
||||
if (varargParam != null && pi >= parameters.length) return false;
|
||||
if (PsiPolyExpressionUtil.isPolyExpression(expression)) return false;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return false;
|
||||
if (exprType instanceof PsiDisjunctionType) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Change 1st parameter of method 'foo' from 'ArrayList<String>' to 'HashSet<E>'" "false"
|
||||
// "<html> Change signature of foo(<s>ArrayList<String></s> <b>HashSet<E></b>)</html>" "false"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// "<html> Change signature of foo(<s>boolean</s> <b>HashSet<E></b>)</html>" "false"
|
||||
import java.util.*;
|
||||
class IntentionIssue {
|
||||
void foo(boolean b) {}
|
||||
void foo(ArrayList<String> lst) {}
|
||||
|
||||
void bar() {
|
||||
foo(new Hash<caret>Set<>());
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,9 @@ import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class ChangeMethodSignatureFromUsage8Test extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
Reference in New Issue
Block a user