Files
swift-mirror/validation-test/Evolution/Inputs/superclass_methods.swift
John McCall afdda3d107 Implement SE-0117.
One minor revision: this lifts the proposed restriction against
overriding a non-open method with an open one.  On reflection,
that was inconsistent with the existing rule permitting non-public
methods to be overridden with public ones.  The restriction on
subclassing a non-open class with an open class remains, and is
in fact consistent with the existing access rule.
2016-08-02 07:46:38 -07:00

75 lines
1.5 KiB
Swift

public func getVersion() -> Int {
#if BEFORE
return 0
#else
return 1
#endif
}
open class Base {
public init() {}
open func method() -> String {
return "Base.method()"
}
open class func classMethod() -> String {
return "Base.classMethod()"
}
}
open class OtherBase {
public init() {}
open func method() -> String {
return "OtherBase.method()"
}
open class func classMethod() -> String {
return "OtherBase.classMethod()"
}
}
open class InBetween : Base {
open override func method() -> String {
return "InBetween.method()"
}
open override class func classMethod() -> String {
return "InBetween.classMethod()"
}
}
#if BEFORE
open class AddInterposingMethod : Base {}
#else
open class AddInterposingMethod : Base {
open override func method() -> String {
return "AddInterposingMethod.method()"
}
open override class func classMethod() -> String {
return "AddInterposingMethod.classMethod()"
}
}
#endif
#if BEFORE
open class RemoveInterposingMethod : Base {
open override func method() -> String {
return "RemoveInterposingMethod.method()"
}
open override class func classMethod() -> String {
return "RemoveInterposingMethod.classMethod()"
}
}
#else
open class RemoveInterposingMethod : Base {}
#endif
#if BEFORE
open class InsertSuperclass : Base {}
#else
open class InsertSuperclass : InBetween {}
#endif
#if BEFORE
open class ChangeRoot : Base {}
#else
open class ChangeRoot : OtherBase {}
#endif