PsiType (@NotNull PsiMethodCallExpression call, @NotNull PsiReferenceExpression methodExpression, @NotNull JavaResolveResult result, @NotNull final LanguageLevel languageLevel, @NotNull PsiFile file) { final PsiMethod method = (PsiMethod)result.getElement(); if (method == null) return null; PsiUtilCore.ensureValid(method); boolean is15OrHigher = languageLevel.compareTo(LanguageLevel.JDK_1_5) >= 0; final PsiType getClassReturnType = PsiTypesUtil.patchMethodGetClassReturnType( call, methodExpression, method, type -> type != JavaElementType.CLASS && type != JavaElementType.ANONYMOUS_CLASS, // enum can be created inside enum only, no need to mention it here languageLevel); if (getClassReturnType != null) { return getClassReturnType; } PsiType ret = method.getReturnType(); if (ret == null) return null; PsiUtil.ensureValidType(ret); if (ret instanceof PsiClassType) { ret = ((PsiClassType)ret).setLanguageLevel(languageLevel); } if (is15OrHigher) { return captureReturnType(call, method, ret, result, languageLevel, file); } return TypeConversionUtil.erasure(ret); }