Masks on mirrored image layers are erroneously mirrored as well

When applying a mask to a mirrored image layer, the mask behaves in a mirrored, non-intuitive way. Moving the mask to the right causes the masking area to go left, moving the mask to the left causes the masking area to go right. And if the mask is rotated by some arbitrary angle, it becomes even more obvious.

Here a mask is applied to a normal, non-mirrored layer:

Here is the same mask when applied to the mirrored layer:

Here is a mask rotated and applied to a non-mirrored layer:

Here is the same mask rotated at the same degree but applied to the mirrored layer: