mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Subclasses of resilient and generic classes now dynamically initialize the vtable by copying the vtable from the superclass, and filling in method overrides. This means we no longer emit references to the base class's methods statically, which allows the base class to add or remove an overload resiliently without invalidating vtables of subclasses already compiled. Note that we still don't know how to slide subclass metadata when the size of superclass metadata changes, so we can't resiliently add or remove vtable entries yet.
39 lines
576 B
Swift
39 lines
576 B
Swift
|
|
public func getVersion() -> Int {
|
|
#if BEFORE
|
|
return 0
|
|
#else
|
|
return 1
|
|
#endif
|
|
}
|
|
|
|
open class AddOverrideBase {
|
|
public init() {}
|
|
|
|
public var description: String {
|
|
return "Base"
|
|
}
|
|
}
|
|
|
|
#if BEFORE
|
|
|
|
open class AddOverrideGeneric<T> : AddOverrideBase {}
|
|
|
|
open class AddOverrideConcrete : AddOverrideBase {}
|
|
|
|
#else
|
|
|
|
open class AddOverrideGeneric<T> : AddOverrideBase {
|
|
override public var description: String {
|
|
return "Generic"
|
|
}
|
|
}
|
|
|
|
open class AddOverrideConcrete : AddOverrideBase {
|
|
override public var description: String {
|
|
return "Concrete"
|
|
}
|
|
}
|
|
|
|
#endif
|