Skip to content

Commit 96c3296

Browse files
committed
Add didSet recursion change to the changelog
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.
1 parent 7cb869a commit 96c3296

File tree

1 file changed

+53
-7
lines changed

1 file changed

+53
-7
lines changed

CHANGELOG.md

Lines changed: 53 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CHANGELOG
66

77
| Contents |
88
| :--------------------- |
9+
| [Swift 5.0](#swift-50) |
910
| [Swift 4.2](#swift-42) |
1011
| [Swift 4.1](#swift-41) |
1112
| [Swift 4.0](#swift-40) |
@@ -20,6 +21,43 @@ CHANGELOG
2021

2122
</details>
2223

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+
class Node {
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+
2361
Swift 4.2
2462
---------
2563

@@ -55,7 +93,7 @@ Swift 4.2
5593
conditionally conforms to `P`, will succeed when the conditional
5694
requirements are met.
5795

58-
**Add new entries to the top of this file, not here!**
96+
**Add new entries to the top of this section, not here!**
5997

6098
Swift 4.1
6199
---------
@@ -276,7 +314,7 @@ Swift 4.0
276314
CFHash and CFEqual as the implementation. This change applies even to "Swift
277315
3 mode", so if you were previously adding this conformance yourself, use
278316
`#if swift(>=3.2)` to restrict the extension to Swift 3.1 and below.
279-
([SR-2388](https://bugs.swift.org/browse/SR-2388))
317+
([SR-2388][])
280318

281319
* [SE-0156][]
282320

@@ -425,7 +463,7 @@ Swift 4.0
425463
slice[i..<j] = buffer[k..<l]
426464
```
427465

428-
* [SR-1529](https://bugs.swift.org/browse/SR-1529):
466+
* [SR-1529][]:
429467

430468
Covariant method overrides are now fully supported, fixing many crashes
431469
and compile-time assertions when defining or calling such methods.
@@ -508,7 +546,7 @@ Swift 3.1
508546
side effects, leading to bugs when Swift code attempted to override
509547
`initialize`.
510548

511-
* [SR-2394](https://bugs.swift.org/browse/SR-2394)
549+
* [SR-2394][]
512550

513551
C functions that "return twice" are no longer imported into Swift. Instead,
514552
they are explicitly made unavailable, so attempting to reference them will
@@ -585,7 +623,7 @@ Swift 3.1
585623
is not guaranteed to work in future versions of Swift, and will
586624
now raise a warning.
587625

588-
* [SR-1446](https://bugs.swift.org/browse/SR-1446)
626+
* [SR-1446][]
589627

590628
Nested types may now appear inside generic types, and nested types may have their own generic parameters:
591629

@@ -605,7 +643,7 @@ Swift 3.1
605643
extension OuterGeneric.InnerGeneric {}
606644
```
607645

608-
* [SR-1009](https://bugs.swift.org/browse/SR-1009):
646+
* [SR-1009][]:
609647

610648
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:
611649

@@ -827,7 +865,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
827865
var x2 = p as! [Int]
828866
```
829867

830-
* [SR-2131](https://bugs.swift.org/browse/SR-2131):
868+
* [SR-2131][]:
831869

832870
The `hasPrefix` and `hasSuffix` functions now consider the empty string to be a prefix and suffix of all strings.
833871

@@ -6915,3 +6953,11 @@ Swift 1.0
69156953
[SE-0197]: <https://github.com/apple/swift-evolution/blob/master/proposals/0197-remove-where.md>
69166954
[SE-0198]: <https://github.com/apple/swift-evolution/blob/master/proposals/0198-playground-quicklook-api-revamp.md>
69176955
[SE-0199]: <https://github.com/apple/swift-evolution/blob/master/proposals/0199-bool-toggle.md>
6956+
6957+
[SR-419]: <https://bugs.swift.org/browse/SR-419>
6958+
[SR-1009]: <https://bugs.swift.org/browse/SR-1009>
6959+
[SR-1446]: <https://bugs.swift.org/browse/SR-1446>
6960+
[SR-1529]: <https://bugs.swift.org/browse/SR-1529>
6961+
[SR-2131]: <https://bugs.swift.org/browse/SR-2131>
6962+
[SR-2388]: <https://bugs.swift.org/browse/SR-2388>
6963+
[SR-2394]: <https://bugs.swift.org/browse/SR-2394>

0 commit comments

Comments
 (0)