mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
75 lines
1.4 KiB
Swift
75 lines
1.4 KiB
Swift
public func getVersion() -> Int {
|
|
#if BEFORE
|
|
return 0
|
|
#else
|
|
return 1
|
|
#endif
|
|
}
|
|
|
|
open class Base {
|
|
public init() {}
|
|
open var property: String {
|
|
return "Base.property"
|
|
}
|
|
open class var classProperty: String {
|
|
return "Base.classProperty"
|
|
}
|
|
}
|
|
|
|
open class OtherBase {
|
|
public init() {}
|
|
open var property: String {
|
|
return "OtherBase.property"
|
|
}
|
|
open class var classProperty: String {
|
|
return "OtherBase.classProperty"
|
|
}
|
|
}
|
|
|
|
open class InBetween : Base {
|
|
open override var property: String {
|
|
return "InBetween.property"
|
|
}
|
|
open override class var classProperty: String {
|
|
return "InBetween.classProperty"
|
|
}
|
|
}
|
|
|
|
#if BEFORE
|
|
open class AddInterposingProperty : Base {}
|
|
#else
|
|
open class AddInterposingProperty : Base {
|
|
open override var property: String {
|
|
return "AddInterposingProperty.property"
|
|
}
|
|
open override class var classProperty: String {
|
|
return "AddInterposingProperty.classProperty"
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if BEFORE
|
|
open class RemoveInterposingProperty : Base {
|
|
open override var property: String {
|
|
return "RemoveInterposingProperty.property"
|
|
}
|
|
open override class var classProperty: String {
|
|
return "RemoveInterposingProperty.classProperty"
|
|
}
|
|
}
|
|
#else
|
|
open class RemoveInterposingProperty : 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
|