Given a class hierarchy such as:
Entity { id, name, position }
Combatant : Entity { health, strength }
Avatar : Combatant { connection }
Which are all immutable.
To implement 'move' on an entity I can return a new entity with a different position.
Entity Move(p) { return new Entity(id, name, p); }
However if I call 'move' on an Avatar, I will get an Entity, not an Avatar. So I have to implement 'move' on all immutable classes. Is there a way to avoid this, or a better solution?