class Animal { static func cast<T: Animal>(animal: Animal) -> T { guard let animal = animal as? T else { fatalError() } return animal } static func bb() -> Self { return cast(animal: Animal()) } }