Dynamic sprite mask

I have a GameObject with the following components: SpriteRenderer, Animator, SpriteMask.
The Animator animation exchanges the sprite of the SpriteRenderer. I want the SpriteMask to change according to the current sprite of the SpriteRenderer. I tried doing spriteMask.sprite = spriteRenderer.sprite; inside the Update method. This exchanges the SpriteMask sprite in the inspector, but the mask itself doesn’t change. Is it even possible to do this in Unity (yet)? Am I missing some kind of “RefreshMask” method on the SpriteMask? (could not find anything like this in the manual / scripting API)

I’m almost sure that for sprites you should use “overrideSprite()” instead. Give it a try:
https://docs.unity3d.com/ScriptReference/UI.Image-overrideSprite.html