Updating Permissions via code not changing "Effective"

In a custom application I'm working on, I'm changing permissions for the Anonymous role via code. The code I'm using is derived from the Orchard.Roles module and works to change the "Allow" permission for the role, but the "Effective"
permission doesn't seem to get updated. If I then go into the UI and click "Save" on the role, the "Effective" permissions are updated.

Is there something I can do via code to affect both the "Allow" AND "Effective" permissions? I would have thought updating the role would affect both. Here's the code: