Do we still get this in Swift 3?
https://github.com/apple/swift/blob/master/docs/GenericsManifesto.md#allowing-subclasses-to-override-requirements-satisfied-by-defaults-
protocol P {}
extension P {
func foo() { print("P") }
}
class C : P {
// gets the protocol extension's
}
class D : C {
/*override not allowed!*/ func foo() { print("D") }
}
let p: P = D()
p.foo() // gotcha: prints "P" rather than "D"!
What will happen if I declare a final computed property or function inside the
default implementation?
protocol P {}
extension P {
final func foo() { print("P") }
}
class C : P {
// gets the protocol extension's
}
class D : C {
/* can not override because of final */ override func foo() { print("D") }
}
let p: P = D()
p.foo() // prints "P"
--
Adrian Zubarev
Sent with Airmail_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution