Change record status: 
Project: 
Introduced in branch: 
10.1.x
Introduced in version: 
10.1.0
Description: 

Drupal\Core\Session\AccountProxy and Drupal\Core\Session\UserSession now implement hasRole() method. It is possible to use the hasRole method on returns of type AccountInterface. For instance:

if (\Drupal::currentUser()->hasRole('foo')) {
  ...
}

AccountInterface do not define this method yet due to BC policies. The method definition will be added in Drupal 11.
See: #3228209: Move hasRole() method from UserInterface to AccountInterface.

Impacts: 
Module developers