PsiType (@NotNull PsiArrayType arrayType, @NotNull PsiMethodCallExpression expression, PsiType itemType) { itemType = GenericsUtil.getVariableTypeByExpressionType(itemType); final PsiType componentType = arrayType.getComponentType(); if (itemType == null || componentType.isAssignableFrom(itemType)) return null; PsiClass componentClass = PsiUtil.resolveClassInClassTypeOnly(componentType); if (componentClass instanceof PsiTypeParameter) { final PsiReferenceList extendsList = ((PsiTypeParameter)componentClass).getExtendsList(); final PsiClassType[] types = extendsList.getReferencedTypes(); if (types.length == 0 || types.length == 1 && types[0].isAssignableFrom(itemType)) return null; } if (itemType instanceof PsiClassType) { final PsiClass aClass = ((PsiClassType)itemType).resolve(); if (aClass instanceof PsiTypeParameter) { final PsiReferenceList extendsList = ((PsiTypeParameter)aClass).getExtendsList(); final PsiClassType[] types = extendsList.getReferencedTypes(); if (types.length == 0) { return TypeUtils.getObjectType(expression); } if (types.length == 1) { return types[0]; } return null; } } return itemType; }