An object is polymorphic when its specific type may vary.
The types a specific value may take, is called class.

It is trivial to copy an object if its type is known:

int x;
int y = x;
Here x is not polymorphic, so y is declared of same type (int) as x.
But if the specific type of x were unknown, then y could not be declared of any specific type.

The task: let a polymorphic object contain an instance of some specific type S derived from a type T.
The type T is known.
The type S is possibly unknown until run time.
The objective is to create an exact copy of such polymorphic object (not to create a reference, nor a pointer to).
Let further the type T have a method overridden by S.
This method is to be called on the copy to demonstrate that the specific type of the copy is indeed S.

class Animal {
    construct new(name, age) {
        _name = name
        _age = age
    }
 
    name { _name }
    age  { _age }
 
    copy() { Animal.new(name, age) }
 
    toString { "Name: %(_name), Age: %(_age)" }
}
 
class Dog is Animal {
    construct new(name, age, breed) {
        super(name, age) // call Animal's constructor
        _breed = breed
    }
 
    // name and age properties will be inherited from Animal 
    breed { _breed }
 
    copy() { Dog.new(name, age, breed) } // overrides Animal's copy() method
 
    toString { super.toString + ", Breed: %(_breed)" } // overrides Animal's toString method
}
 
var a = Dog.new("Rover", 3, "Terrier") // a's type is Dog
var b = a.copy() // a's copy() method is called and so b's type is Dog
System.print("Dog 'a' -> %(a)") // implicitly calls a's toString method
System.print("Dog 'b' -> %(b)") // ditto
System.print("Dog 'a' is %((Object.same(a, b)) ? "" : "not") the same object as Dog 'b'")