PsiType (@NotNull PsiMethodReferenceExpression expression, @NotNull JavaResolveResult result) { PsiSubstitutor subst = result.getSubstitutor(); PsiType methodReturnType = null; PsiClass containingClass = null; final PsiElement resolve = result.getElement(); if (resolve instanceof PsiMethod) { containingClass = ((PsiMethod)resolve).getContainingClass(); methodReturnType = PsiTypesUtil.patchMethodGetClassReturnType(expression, (PsiMethod)resolve); if (methodReturnType == null) { methodReturnType = ((PsiMethod)resolve).getReturnType(); if (PsiTypes.voidType().equals(methodReturnType)) { return methodReturnType; } methodReturnType = subst.substitute(methodReturnType); } } else if (resolve instanceof PsiClass) { if (PsiUtil.isArrayClass(resolve)) { final PsiTypeParameter[] typeParameters = ((PsiClass)resolve).getTypeParameters(); if (typeParameters.length == 1) { final PsiType arrayComponentType = subst.substitute(typeParameters[0]); if (arrayComponentType == null) { return null; } methodReturnType = arrayComponentType.createArrayType(); } } containingClass = (PsiClass)resolve; } if (methodReturnType == null) { if (containingClass == null) { return null; } methodReturnType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(containingClass, subst); } return PsiUtil.captureToplevelWildcards(methodReturnType, expression); }