diff --git a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java index 3d228a2b262d..a3526b3976e8 100644 --- a/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java +++ b/java/java-psi-api/src/com/intellij/psi/PsiMethodReferenceUtil.java @@ -104,12 +104,10 @@ public class PsiMethodReferenceUtil { final PsiElement resolve = result.getElement(); if (resolve instanceof PsiMethod) { containingClass = ((PsiMethod)resolve).getContainingClass(); - - PsiType returnType = PsiTypesUtil.patchMethodGetClassReturnType(expression, expression, (PsiMethod)resolve, null, PsiUtil.getLanguageLevel(expression)); - - if (returnType == null) { - returnType = ((PsiMethod)resolve).getReturnType(); - if (PsiType.VOID.equals(returnType)) { + methodReturnType = PsiTypesUtil.patchMethodGetClassReturnType(expression, expression, (PsiMethod)resolve, null, PsiUtil.getLanguageLevel(expression)); + if (methodReturnType == null) { + methodReturnType = ((PsiMethod)resolve).getReturnType(); + if (PsiType.VOID.equals(methodReturnType)) { return false; } @@ -120,14 +118,11 @@ public class PsiMethodReferenceUtil { LOG.assertTrue(subst != null); } - methodReturnType = subst.substitute(returnType); + methodReturnType = subst.substitute(methodReturnType); if (methodReturnType != null) { methodReturnType = PsiUtil.captureToplevelWildcards(methodReturnType, expression); } } - else { - methodReturnType = returnType; - } } else if (resolve instanceof PsiClass) { if (resolve == JavaPsiFacade.getElementFactory(expression.getProject()).getArrayClass(PsiUtil.getLanguageLevel(resolve))) {