Files
swift-mirror/validation-test/Evolution/Inputs/class_insert_superclass.swift
Slava Pestov 9af20c71f0 Evolution: Clean up superclass insertion tests a bit
- 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.
2018-11-29 23:20:02 -05:00

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