xAlien95
(Stefano De Carolis)
4
You can simplify your example with a property:
protocol P {
var foo: Int { get }
}
protocol Q: P {
var foo: Int { set }
}
// error: variable with a setter must also have a getter
// var foo: Int { set }
// ^
This may be due to the fact that P's .foo property may be different from Q's .foo property if you provide a default implementation in a protocol extension, so it should be defined independently.
I still need to understand how variable overloading really works behind the scenes in Swift. This thread may be related:
4 Likes