How can I override template_preprocess_file_link function?
Yes, seems you need to add:

use Drupal\file\Entity\File;


to the begin of your mytheme.theme file. You can also do something like:

$file_entity = $file instanceof \Drupal\file\Entity\File ? $file : 
\Drupal\file\Entity\File::load($file-&gt;fid);


And you will have the same problem with Attribute and Url. You need to import the classes with the complet namespace in your file. https://secure.php.net/manual/en/language.namespaces.importing.php