protocol Animal { func foo() -> Self } class Cat: Animal { func foo() -> Self { return self } } class Siamese: Cat { } let siamese = Siamese() let cat = siamese.foo()
return self
type(of: self).init()
Self