Replacing an object of the UserLoginForm class with one of my own class
As I said in the question, the problem was that UserController::userPage() expressly created an object of the class UserLoginForm. The method has been changed, and now it contains the following code, which doesn't contain any explicit reference to that class.

public function userPage() {
  return $this-&gt;redirect('entity.user.canonical', array('user' =&gt; $this-&gt;currentUser()-&gt;id()));
}


Using a route subscriber that extends RouteSubscriberBase is possible to change the form associated with a route.

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

class MymoduleRouteSubscriber extends RouteSubscriberBase {
  public function alterRoutes(RouteCollection $collection) {
    if ($route = $collection-&gt;get('user.login')) {
      $route-&gt;setDefault('_form', '\Drupal\mymodule\Form\MyModuleLoginForm');
    }
  }
}