I am messing around with LLVM right now, and the question came to my mind: How is Swift able to achieve extensions at the binary level?
In Swift, one can provide a basic extension that simply adds methods, but they can also provide an extension that conforms to another protocol. This class is then recognized as having said protocol as a parent and they can be casted from one another. How is this achieved?
I know about vtables and that they can define the location of function definitions and whatnot, but to my knowledge they are fixed length, correct? Is Swift able to achieve this functionality through its runtime library or are types mapped to lower level LLVM and it somehow manipulates the vtables whenever a new extension is defined?