PsiType (@NotNull PsiMethod method) { if (method instanceof GrMethod) { GrTypeElement typeElement = ((GrMethod)method).getReturnTypeElementGroovy(); if (typeElement != null) return typeElement.getType(); } final PsiType smartReturnType = PsiUtil.getSmartReturnType(method); if (smartReturnType != null && !PsiTypes.nullType().equals(smartReturnType)) return smartReturnType; if (PsiTypes.nullType().equals(smartReturnType) && PsiUtil.isVoidMethod(method)) return PsiTypes.voidType(); //todo make smarter. search for usages and infer type from them return TypesUtil.getJavaLangObject(method); }