Why can't computed properties be overloaded (like methods can)?

Another answer:

struct S<A> {
    var foo = 123
}

extension S where A: FixedWidthInteger {
    var foo: Int { 321 }
}

var intS = S<Int>()
intS.foo = 0
print(intS.foo) // 321. How can we get the zero?

func f<T: Any>(_ s: S<T>) -> Int { s.foo } // <-- Like this.
print(f(intS)) // 0
2 Likes