mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Don't re-dispatch to the override's vtable slot if the override is final; there's no vtable slot and this will result in an infinite loop. Fixes <rdar://problem/52006394>.
29 lines
513 B
Swift
29 lines
513 B
Swift
|
|
open class Base {
|
|
public init() {}
|
|
|
|
fileprivate func privateMethod() -> Int {
|
|
return 1
|
|
}
|
|
}
|
|
|
|
open class Derived : Base {
|
|
open override func privateMethod() -> Int {
|
|
return super.privateMethod() + 1
|
|
}
|
|
}
|
|
|
|
public final class FinalDerived : Base {
|
|
public override func privateMethod() -> Int {
|
|
return super.privateMethod() + 1
|
|
}
|
|
}
|
|
|
|
public func callBaseMethod(_ b: Base) -> Int {
|
|
return b.privateMethod()
|
|
}
|
|
|
|
public func callDerivedMethod(_ d: Derived) -> Int {
|
|
return d.privateMethod()
|
|
}
|