如何调用具有与此 class 同名函数的 class 的静态方法?

How to call static method of a class that has a function with the same name as this class?

在我使用 Swift 3.3 创建的应用程序中,我有以下 class:

class A {

    func A() {

    }
}

现在我需要创建一个带有静态函数和调用此静态函数的非静态函数的扩展。我有这个草稿:

extension A {

    static func staticFunc() {

    }

    func f() {

        A.staticFunc()
    }
}

但是这段代码是不可编译的。我该如何解决这个问题?我无法删除或重命名 func A。迁移到 Swift 4.1 并没有解决问题。

如果无法重命名函数,则使用(本地)类型别名 可以定义为解决方法:

extension A {
    typealias AliasA = A

    static func staticFunc() { }

    func f() {
        AliasA.staticFunc()
    }
}

type(of: self).staticFunc() 应该可以。 type(of: self) 采用 self 的类型并 returns 它。