remove wrong capture treatment: the completion result is incorrect (IDEA-155188)
authorpeter <peter@jetbrains.com>
Tue, 3 May 2016 12:20:26 +0000 (14:20 +0200)
committerpeter <peter@jetbrains.com>
Tue, 3 May 2016 12:25:59 +0000 (14:25 +0200)
java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/LambdaWithCapturedSuperWildcardInAmbiguousCall.java [deleted file]
java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal8CompletionTest.groovy

index 998e8bec4d2cd1758067299c184a157cdd488945..fe139162f1bcebbce7ca983add6da7d93811c4ec 100644 (file)
@@ -270,7 +270,10 @@ public class JavaCompletionUtil {
               final int parameterIndex = lambdaExpression.getParameterList().getParameterIndex((PsiParameter)resolve);
               final Set<LookupElement> set = new LinkedHashSet<LookupElement>();
               final boolean overloadsFound = LambdaUtil.processParentOverloads(lambdaExpression, functionalInterfaceType -> {
-                PsiType qualifierType = removeTopLevelWildcards(LambdaUtil.getLambdaParameterFromType(functionalInterfaceType, parameterIndex));
+                PsiType qualifierType = LambdaUtil.getLambdaParameterFromType(functionalInterfaceType, parameterIndex);
+                if (qualifierType instanceof PsiWildcardType) {
+                  qualifierType = ((PsiWildcardType)qualifierType).getBound();
+                }
                 if (qualifierType == null) return;
 
                 PsiReferenceExpression fakeRef = createReference("xxx.xxx", createContextWithXxxVariable(element, qualifierType));
@@ -285,17 +288,6 @@ public class JavaCompletionUtil {
     return processJavaQualifiedReference(element, javaReference, elementFilter, options, matcher, parameters);
   }
 
-  @Nullable
-  private static PsiType removeTopLevelWildcards(@Nullable PsiType qualifierType) {
-    if (qualifierType instanceof PsiCapturedWildcardType) {
-      return removeTopLevelWildcards(((PsiCapturedWildcardType)qualifierType).getWildcard());
-    }
-    if (qualifierType instanceof PsiWildcardType) {
-      return removeTopLevelWildcards(((PsiWildcardType)qualifierType).getBound());
-    }
-    return qualifierType;
-  }
-
   private static Set<LookupElement> processJavaQualifiedReference(PsiElement element, PsiJavaReference javaReference, ElementFilter elementFilter,
                                                         JavaCompletionProcessor.Options options,
                                                         final PrefixMatcher matcher, CompletionParameters parameters) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/LambdaWithCapturedSuperWildcardInAmbiguousCall.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/completion/normal/LambdaWithCapturedSuperWildcardInAmbiguousCall.java
deleted file mode 100644 (file)
index 523e3e0..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-import java.util.stream.*;
-import java.util.*;
-
-class Foo {
-  void main(Stream<? super String> stream) {
-    stream.collect(Collectors.toMap(o -> o.sub<caret>))
-  }
-}
\ No newline at end of file
index 59d79b00073bf2f7b5d58b2f9b0bd0bb93253c6e..b671bc48369525988aa80c7044ee012741d5c3c2 100644 (file)
@@ -249,10 +249,6 @@ class Test88 {
     configureByTestName()
     myFixture.assertPreferredCompletionItems(0, 'substring', 'substring', 'subSequence')
   }
-  public void testLambdaWithCapturedSuperWildcardInAmbiguousCall() {
-    configureByTestName()
-    myFixture.assertPreferredCompletionItems(0, 'substring', 'substring', 'subSequence')
-  }
   public void testUnexpectedLambdaInAmbiguousCall() { doAntiTest() }
 
   public void testNoCollectorsInComment() { doAntiTest() }