示例工程 10-protocols

10-protocols/Diagnostics/MismatchedDefault.swift

swift · 0.3 KB

// 故意编译失败:扩展方法的签名与协议要求不一致,不能算满足要求。
// 复现:swiftc Diagnostics/MismatchedDefault.swift
protocol P {
    func f() -> String
}
 
extension P {
    func f() -> Int { 1 }
}
 
struct S: P {}
 
print(S().f())