mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- We don't want to support changing a root class of a class, so don't
pretend that works. Some of these tests got removed recently in
d8104e7e43 but one still remained.
- For the tests that insert a non-root superclass in the inheritance
hierarchy, also test calling a method of the derived class. This
works now that we no longer hardcode vtable offsets and instead use
dispatch thunks.
93 lines
1.2 KiB
Swift
93 lines
1.2 KiB
Swift
open class Root {}
|
|
|
|
#if BEFORE
|
|
|
|
open class FirstMiddle : Root {
|
|
let x: String
|
|
|
|
public init(x: String) {
|
|
self.x = x
|
|
}
|
|
|
|
public func get() -> String {
|
|
return x
|
|
}
|
|
}
|
|
|
|
open class SecondMiddle : Root {
|
|
let x: String
|
|
|
|
public init(x: String) {
|
|
self.x = x
|
|
}
|
|
|
|
public func get() -> String {
|
|
return x
|
|
}
|
|
}
|
|
|
|
open class GenericMiddle<T> : Root {
|
|
let x: T
|
|
|
|
public init(x: T) {
|
|
self.x = x
|
|
}
|
|
|
|
public func get() -> T {
|
|
return x
|
|
}
|
|
}
|
|
|
|
#else
|
|
|
|
// Insert concrete superclass
|
|
open class Base : Root {
|
|
let x: String
|
|
|
|
public init(t: String) {
|
|
self.x = t
|
|
}
|
|
}
|
|
|
|
open class FirstMiddle : Base {
|
|
public init(x: String) {
|
|
super.init(t: x)
|
|
}
|
|
|
|
public func get() -> String {
|
|
return x
|
|
}
|
|
}
|
|
|
|
// Insert generic superclass
|
|
open class GenericBase<T> : Root {
|
|
let x: T
|
|
|
|
public init(t: T) {
|
|
self.x = t
|
|
}
|
|
}
|
|
|
|
open class SecondMiddle : GenericBase<String> {
|
|
public init(x: String) {
|
|
super.init(t: x)
|
|
}
|
|
|
|
public func get() -> String {
|
|
return x
|
|
}
|
|
}
|
|
|
|
// Insert concrete superclass - class itself is generic
|
|
open class GenericMiddle<T> : GenericBase<T> {
|
|
public init(x: T) {
|
|
super.init(t: x)
|
|
}
|
|
|
|
public func get() -> T {
|
|
return x
|
|
}
|
|
}
|
|
|
|
#endif
|