Suppose we have a class and it’s subclass. We know that virtual table for second class has methods from superClass with changed addresses for overridden methods, and added methods from subclass is added at the end of the table. But when we have a call from subclass to it’s superclass, how is superclass method implementation address found from virtual table when there’s no address for that method in subclass vtable as it’s overridden.
class ParentClass {
func method1() {
print("method 1")
}
}
class Subclass : ParentClass {
override func method1() {
super.method1()
print("method 1 override")
}
func method2() {
print("method 2")
}
}
[1]: https://i.sstatic.net/jtIbHlYF.png