mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-182988 Spurious collection cast on completion Set -> HashSet
This commit is contained in:
@@ -44,6 +44,7 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import com.siyeh.ig.psiutils.SideEffectChecker;
|
||||
import gnu.trove.THashSet;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -364,7 +365,9 @@ public class JavaCompletionUtil {
|
||||
PsiMethod method = (PsiMethod)o;
|
||||
PsiClassType.ClassResolveResult plainResult = ((PsiClassType)plainQualifier).resolveGenerics();
|
||||
PsiClass plainClass = plainResult.getElement();
|
||||
if (plainClass != null && plainClass.findMethodBySignature(method, true) != null) {
|
||||
HierarchicalMethodSignature signature = method.getHierarchicalMethodSignature();
|
||||
if (plainClass != null && StreamEx.of(signature.getSuperSignatures()).prepend(signature)
|
||||
.anyMatch(sig -> MethodSignatureUtil.findMethodBySignature(plainClass, sig, true) != null)) {
|
||||
PsiClass castClass = ((PsiClassType)castType).resolveGenerics().getElement();
|
||||
|
||||
if (castClass == null || !castClass.isInheritor(plainClass, true)) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
class Foo {
|
||||
void test() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.computeIfAb<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import java.util.*;
|
||||
|
||||
class Foo {
|
||||
void test() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.computeIfAbsent()
|
||||
}
|
||||
}
|
||||
+1
@@ -49,6 +49,7 @@ class NormalCompletionDfaTest extends NormalCompletionTestCase {
|
||||
void testFieldWithCastingCaret() { doTest() }
|
||||
void testCastWhenMethodComesFromDfaSuperType() { doTest() }
|
||||
void testGenericTypeDfa() { doTest() }
|
||||
void testNoUnnecessaryCastDfa() { doTest() }
|
||||
|
||||
void testCastTwice() {
|
||||
configureByTestName()
|
||||
|
||||
Reference in New Issue
Block a user