mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: ensure to insert valid specification (IDEA-161992)
This commit is contained in:
@@ -27,6 +27,7 @@ import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.RedundantCastUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -127,7 +128,7 @@ public class InlineUtil {
|
||||
if (substituted == null) break;
|
||||
copy.getTypeArgumentList().add(elementFactory.createTypeElement(substituted));
|
||||
}
|
||||
if (varType.equals(copy.getType())) {
|
||||
if (varType.equals(copy.getType()) && copy.resolveMethodGenerics().isValidResult()) {
|
||||
((PsiCallExpression)expr).getTypeArgumentList().replace(copy.getTypeArgumentList());
|
||||
return (PsiMethod)resolved;
|
||||
}
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
class Main {
|
||||
public Collection<? extends Number> get() {
|
||||
List<Number> lis<caret>t = IntStream.range(0, 100).boxed().collect(Collectors.toList());
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
class Main {
|
||||
public Collection<? extends Number> get() {
|
||||
return IntStream.range(0, 100).boxed().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -292,6 +292,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
"Variable 'hello' is accessed for writing");
|
||||
}
|
||||
|
||||
public void testAvoidTypeSpecificationWhenPossibleToAvoid() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean inlineDef, String conflictMessage) throws Exception {
|
||||
try {
|
||||
doTest(inlineDef);
|
||||
|
||||
Reference in New Issue
Block a user