boolean (PsiType type) { if (type instanceof PsiArrayType) { return isReifiableType(((PsiArrayType)type).getComponentType()); } if (type instanceof PsiPrimitiveType) { return true; } if (PsiUtil.resolveClassInType(type) instanceof PsiTypeParameter) { return false; } if (type instanceof PsiClassType) { final PsiClassType classType = (PsiClassType)PsiUtil.convertAnonymousToBaseType(type); if (classType.isRaw()) { return true; } PsiType[] parameters = classType.getParameters(); if (parameters.length > 0) { for (PsiType parameter : parameters) { if (!(parameter instanceof PsiWildcardType && ((PsiWildcardType)parameter).getBound() == null)) { return false; } } return true; } final PsiClassType.ClassResolveResult resolved = classType.resolveGenerics(); final PsiClass aClass = resolved.getElement(); if (aClass instanceof PsiTypeParameter) { return false; } if (aClass != null && !aClass.hasModifierProperty(PsiModifier.STATIC)) { //local class (inner inside inside anonymous) should skip anonymous as it can't be static itself final PsiClass stopClassLevel = PsiUtil.isLocalClass(aClass) ? null : aClass.getContainingClass(); PsiModifierListOwner enclosingStaticElement = PsiUtil.getEnclosingStaticElement(aClass, stopClassLevel); PsiClass containingClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class, true); if (containingClass != null && (enclosingStaticElement == null || PsiTreeUtil.isAncestor(enclosingStaticElement, containingClass, false))) { //anonymous classes are not generic while (containingClass instanceof PsiAnonymousClass) { containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class, true); } if (containingClass == null || enclosingStaticElement != null && !PsiTreeUtil.isAncestor(enclosingStaticElement, containingClass, false)) { return true; } return isReifiableType(JavaPsiFacade.getElementFactory(aClass.getProject()).createType(containingClass, resolved.getSubstitutor())); } } return true; } if (type instanceof PsiCapturedWildcardType) { return isReifiableType(((PsiCapturedWildcardType)type).getUpperBound()); } return false; }