Equivalent of class methods, but for protocols (Factory Methods / Class Clusters)

The above self return the concrete type not the protocol metatype.


protocol Feline {
    static func purr() -> Feline
}

struct Cat {}
extension Cat: Feline {}

extension Feline { // These methods do not get attached to the feline metatype and can only be called via their concrete types.
    static func purr() -> Feline {
        return Cat()
    }
    
    static func meow() -> Cat {
        return Cat()
    }
}

let concreteCat:Cat = .meow() // Okay
let felineMeta:Feline = Cat.purr() // Okay


let someCat:Cat = Feline.meow() // error: static member 'meow' cannot be used on protocol metatype 'Feline.Protocol'
let someFeline:Feline = .purr() // error: static member 'purr' cannot be used on protocol metatype 'Feline.Protocol'