method refs: ensure non-resolved method refs are not marked as exact (EA-59172 -...
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 25 Feb 2015 19:20:13 +0000 (20:20 +0100)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Wed, 25 Feb 2015 19:34:39 +0000 (20:34 +0100)
java/java-psi-impl/src/com/intellij/psi/impl/source/tree/java/PsiMethodReferenceExpressionImpl.java
java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureNotResolvedMethodRefsAreNotMarkedAsExact.java [new file with mode: 0644]
java/java-tests/testSrc/com/intellij/codeInsight/daemon/lambda/NewMethodRefHighlightingTest.java

index e640caf1f80269babb03fa9d12eccadb10b1d7fc..60b3b5f9bcee8d253efbbfeb7ceea2a282ecad26 100644 (file)
@@ -151,6 +151,10 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
             result.add(signature.getMethod());
           }
         }
+
+        if (result.isEmpty()) {
+          return null;
+        }
         methods = result.toArray(new PsiMethod[result.size()]);
       }
       else if (isConstructor()) {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureNotResolvedMethodRefsAreNotMarkedAsExact.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/lambda/newMethodRef/EnsureNotResolvedMethodRefsAreNotMarkedAsExact.java
new file mode 100644 (file)
index 0000000..e6d5ecf
--- /dev/null
@@ -0,0 +1,10 @@
+import java.util.function.Function;
+
+class Test<A> {
+  class P {
+    {
+      g(P::<error descr="Cannot resolve method 'aa'">aa</error>);
+    }
+  }
+  <R> void g(Function<R, String> r){}
+}
\ No newline at end of file
index dad206251e3e56a9c9a567a55a41f1c734a4ad50..c4338babb5a50351d67b77d423671a9fad233e5f 100644 (file)
@@ -386,6 +386,10 @@ public class NewMethodRefHighlightingTest extends LightDaemonAnalyzerTestCase {
     doTest();
   }
 
+  public void testEnsureNotResolvedMethodRefsAreNotMarkedAsExact() throws Exception {
+    doTest();
+  }
+
   private void doTest() {
     doTest(false);
   }