Well, it means being able to use copy constructors. Why do we need to be able to define them in Swift for this? If we look at an example:
//C++
struct X { X(const X &); };
// Swift
struct Y : X { var i : Int }
// IR
swift.Y = type { X, Int }
The subclass essentially turns into a member and we can just decompose and emit the respective copy logic for each class, in this case, we'll call out to X
's copy constructor and simply copy i
as any other POD type.
The user of X
doesn't need to do anything "special" we have the ability to handle this entirely in the compiler (I think). Here's a proof of concept if you're interested.