您如何区分已实现协议的静态方法之间的歧义?

How do you disambiguate between static methods from implemented protocols?

转换对于实例函数来说工作得很好。

protocol Protocol1 {}
extension Protocol1 {
    func instanceFunc() {}
    static func staticFunc() {}
}

protocol Protocol2 {}
extension Protocol2 {
    func instanceFunc() {}
    static func staticFunc() {}
}

struct Struct: Protocol1, Protocol2 {
    func instanceFunc() {
        (self as Protocol1).instanceFunc()
        (self as Protocol2).instanceFunc()
    }

    static func staticFunc() {
        // My best guess. Nope!
        (Struct as Protocol1.Type).staticFunc()
        (Struct as Protocol2.Type).staticFunc()
    }
}

这应该可以解决问题,伙计

protocol Protocol1 {}
extension Protocol1 {
    func instanceFunc() {}
    static func staticFunc() {}
}

protocol Protocol2 {}
extension Protocol2 {
    func instanceFunc() {}
    static func staticFunc() {}
}

struct Struct: Protocol1, Protocol2 {
    func instanceFunc() {
        (self as Protocol1).instanceFunc()
        (self as Protocol2).instanceFunc()
    }

    static func staticFunc() {
        (Struct.self as Protocol1.Type).staticFunc()
        (Struct.self as Protocol2.Type).staticFunc()
    }
}