My interpretation of the proposal is that it changes the exclusivity rule when oldValue
is not used (technically it's source breaking, but in a way that simplifies the rules).
I'm strongly in favor of this proposal along with John's suggestion of modifying in-place unconditionally. It's very confusing for Swift to exhibit different behavior due to a seemingly unrelated change. The following should be an exclusivity violation regardless of whether bar
has a didSet
observer, and regardless of whether the observer references oldValue
. Currently, the compiler fails to enforce this.
public class C {
var bar: Int = 0
{ didSet { _ = oldValue } } // nothing on this line should affect exclusivity enforcement.
}
func testBar(_ x: inout Int, _ c: C) {
x = 1
c.bar = 2 // simultaneous access to "bar"
}
public func test(c: C) {
testBar(&c.bar, c) // "bar" originally accessed here
}