diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java index 0554a0f7a96b..645aac0e78f7 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/PreferByKindWeigher.java @@ -139,8 +139,8 @@ public class PreferByKindWeigher extends LookupElementWeigher { if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) { return MyResult.probableKeyword; } - if (PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) { - boolean inReturn = PsiTreeUtil.getParentOfType(myPosition, PsiReturnStatement.class, false, PsiMember.class) != null; + if ((PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) && myCompletionType == CompletionType.SMART) { + boolean inReturn = psiElement().withParents(PsiReferenceExpression.class, PsiReturnStatement.class).accepts(myPosition); return inReturn ? MyResult.probableKeyword : MyResult.normal; } if (PsiKeyword.INTERFACE.equals(keyword) && psiElement().afterLeaf("@").accepts(myPosition)) { diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy index b050bd7c5ced..824c62cf3004 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy +++ b/java/java-tests/testSrc/com/intellij/codeInsight/completion/NormalCompletionTest.groovy @@ -792,7 +792,7 @@ public class ListUtils { public void testDoubleFalse() throws Throwable { configureByFile(getTestName(false) + ".java"); - assertFirstStringItems("false", "fefefef", "float", "finalize"); + assertFirstStringItems("fefefef", "false", "float", "finalize"); } public void testSameNamedVariableInNestedClasses() throws Throwable {