import Foundation
protocol Provider {
var value: String? { get }
}
extension Provider {
var value: String? { nil }
}
struct Struct: Provider {
// Depending on property's type printValue prints either "123" or nil.
// For `String` output is "nil", for `String?` output is "123".
var value: String
}
func printValue(_ value: some Provider) {
print(value.value ?? "nil")
}
let s = Struct(value: "123")
printValue(s)
Looks fair to me, if the type is different you are overloading "value" with something unrelated which is not used when accessing the protocol member, and given there's default implementation there is no compilation error.