diff --git a/core/modules/user/lib/Drupal/user/Entity/Role.php b/core/modules/user/lib/Drupal/user/Entity/Role.php
index 320d7f0..f877730 100644
--- a/core/modules/user/lib/Drupal/user/Entity/Role.php
+++ b/core/modules/user/lib/Drupal/user/Entity/Role.php
@@ -125,12 +125,12 @@ public static function postLoad(EntityStorageControllerInterface $storage_contro
   public function preSave(EntityStorageControllerInterface $storage_controller) {
     parent::preSave($storage_controller);
 
-    if (!isset($this->weight) && ($roles = $storage_controller->loadMultiple())) {
+    if ($this->getWeight() && ($roles = $storage_controller->loadMultiple())) {
       // Set a role weight to make this new role last.
       $max = array_reduce($roles, function($max, $role) {
-        return $max > $role->weight ? $max : $role->weight;
+        return $max > $role->getWeight() ? $max : $role->getWeight();
       });
-      $this->weight = $max + 1;
+      $this->setWeight($max + 1);
     }
   }
 
@@ -156,4 +156,19 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
     Cache::invalidateTags(array('role' => $ids));
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getWeight() {
+    return $this->weight;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function setWeight($weight) {
+    $this->weight = $weight;
+    return $this->weight;
+  }
+
 }
diff --git a/core/modules/user/lib/Drupal/user/RoleInterface.php b/core/modules/user/lib/Drupal/user/RoleInterface.php
index 7160a8e..b7fb664 100644
--- a/core/modules/user/lib/Drupal/user/RoleInterface.php
+++ b/core/modules/user/lib/Drupal/user/RoleInterface.php
@@ -55,4 +55,23 @@ public function grantPermission($permission);
    */
   public function revokePermission($permission);
 
+  /**
+   * Returns the weight.
+   *
+   * @return int
+   *   The weight of this role.
+   */
+  public function getWeight();
+
+  /**
+   * Sets the weight to the given value.
+   *
+   * @param int $weight
+   *   The desired weight.
+   *
+   * @return \Drupal\user\RoleStorageControllerInterface
+   *   The class instance this method is called on.
+   */
+  public function setWeight($weight);
+
 }
