You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In swiftlang#15280 we changed the behaviour of setting a property within its own `didSet` or `willSet` observer, such that we only perform direct accesses on `self` in Swift 5 mode.
This commit adds this to the changelog and, in addition, does some gardening for the SR links.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+53-7Lines changed: 53 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ CHANGELOG
6
6
7
7
| Contents |
8
8
| :--------------------- |
9
+
|[Swift 5.0](#swift-50)|
9
10
|[Swift 4.2](#swift-42)|
10
11
|[Swift 4.1](#swift-41)|
11
12
|[Swift 4.0](#swift-40)|
@@ -20,6 +21,43 @@ CHANGELOG
20
21
21
22
</details>
22
23
24
+
Swift 5.0
25
+
---------
26
+
27
+
-[SR-419][]
28
+
29
+
In Swift 5 mode, when setting a property from within its own `didSet` or `willSet` observer, the observer will now only avoid being recursively called if the property is set on `self` (either implicitly or explicitly).
30
+
31
+
For example:
32
+
```swift
33
+
classNode {
34
+
var children = [Node]()
35
+
36
+
var depth: Int {
37
+
didSet {
38
+
if depth <0 {
39
+
// Will not recursively call didSet, as setting depth on self (same
40
+
// with `self.depth = 0`).
41
+
depth =0
42
+
}
43
+
44
+
// Will call didSet for each of the children, as we're not setting the
45
+
// property on self (prior to Swift 5, this did not trigger property
46
+
// observers to be called again).
47
+
for child in children {
48
+
child.depth= depth +1
49
+
}
50
+
}
51
+
}
52
+
53
+
init(depth: Int) {
54
+
self.depth= depth
55
+
}
56
+
}
57
+
```
58
+
59
+
**Add new entries to the top of this section, not here!**
60
+
23
61
Swift 4.2
24
62
---------
25
63
@@ -55,7 +93,7 @@ Swift 4.2
55
93
conditionally conforms to `P`, will succeed when the conditional
56
94
requirements are met.
57
95
58
-
**Add new entries to the top of this file, not here!**
96
+
**Add new entries to the top of this section, not here!**
59
97
60
98
Swift 4.1
61
99
---------
@@ -276,7 +314,7 @@ Swift 4.0
276
314
CFHash and CFEqual as the implementation. This change applies even to "Swift
277
315
3 mode", so if you were previously adding this conformance yourself, use
278
316
`#ifswift(>=3.2)` to restrict the extension to Swift 3.1 and below.
Constrained extensions allow same-type constraints between generic parameters and concrete types. This enables you to create extensions, for example, on `Array` with `Int` elements:
611
649
@@ -827,7 +865,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
0 commit comments