diff --git a/java/java-psi-impl/src/com/intellij/psi/scope/util/PsiScopesUtil.java b/java/java-psi-impl/src/com/intellij/psi/scope/util/PsiScopesUtil.java index c1fce0e27bc0..2a1a6f65301d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/scope/util/PsiScopesUtil.java +++ b/java/java-psi-impl/src/com/intellij/psi/scope/util/PsiScopesUtil.java @@ -199,7 +199,7 @@ public class PsiScopesUtil { substitutor = substitutor.putAll((PsiClass)target, types); } } - else if (target instanceof PsiClass) { + else if (target instanceof PsiClass && !(ref instanceof PsiMethodReferenceExpression)) { processor.handleEvent(JavaScopeProcessorEvent.START_STATIC, null); } } diff --git a/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic.java b/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic.java new file mode 100644 index 000000000000..e79f79c3a52d --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic.java @@ -0,0 +1,8 @@ +import java.util.*; + +class Test { + void aaa(Test p) { return 1; } + void test() { + Comparator r2 = Test:: + } +} diff --git a/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic_after.java b/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic_after.java new file mode 100644 index 000000000000..2680fa9b2836 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completion/normal/MethodReferenceNoStatic_after.java @@ -0,0 +1,8 @@ +import java.util.*; + +class Test { + void aaa(Test p) { return 1; } + void test() { + Comparator r2 = Test::test; + } +} diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java index 5e676ae6d597..fe96da3cd6a4 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/KeywordCompletionTest.java @@ -99,7 +99,7 @@ public class KeywordCompletionTest extends LightCompletionTestCase { public void testDefaultInExtMethod() throws Exception { doTest(false); } public void testNullInMethodCall() throws Exception { doTest(true); } public void testNullInMethodCall2() throws Exception { doTest(false); } - public void testNewInMethodRefs() throws Exception { doTest(false); } + public void testNewInMethodRefs() throws Exception { doTest(1, "new"); } public void testSpaceAfterInstanceof() throws Exception { doTest(false); } public void testAbstractInInterface() throws Exception { doTest(1, "abstract"); } public void testCharInAnnotatedParameter() throws Exception { doTest(1, "char"); } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal17CompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal17CompletionTest.groovy index 98256866a1c1..8f833b43222a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal17CompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/Normal17CompletionTest.groovy @@ -39,6 +39,8 @@ public class Normal17CompletionTest extends LightFixtureCompletionTestCase { public void testOnlyResourcesInResourceList3() { doTest() } public void testOnlyResourcesInResourceList4() { doTest() } + public void testMethodReferenceNoStatic() { doTest() } + public void testResourceParentInResourceList() { configureByFile(getTestName(false) + ".java") assert 'MyOuterResource' == myFixture.lookupElementStrings[0]