Skip to content

Commit d366941

Browse files
authored
[Changelog] Mention SR-7083 in changelog under Swift 5.3 (#31457)
1 parent 2d10a3d commit d366941

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ CHANGELOG
2727
Swift 5.3
2828
----------
2929

30+
* [SR-7083][]:
31+
32+
Property observers such as `willSet` and `didSet` are now supported on `lazy` properties:
33+
34+
```swift
35+
class C {
36+
lazy var property: Int = 0 {
37+
willSet { print("willSet called!") } // Okay
38+
didSet { print("didSet called!") } // Okay
39+
}
40+
}
41+
```
42+
43+
Note that the initial value of the property will be forced and made available as the `oldValue` for the `didSet` observer, if the property hasn't been accessed yet.
44+
45+
```swift
46+
class C {
47+
lazy var property: Int = 0 {
48+
didSet { print("Old value: ", oldValue) }
49+
}
50+
}
51+
52+
let c = C()
53+
c.property = 1 // Prints 'Old value: 0'
54+
```
55+
56+
This could have side-effects, for example if the lazy property's initializer is doing other work.
57+
3058
* [SE-0268][]:
3159

3260
A `didSet` observer which does not refer to the `oldValue` in its body or does not explicitly request it by placing it in the parameter list (i.e. `didSet(oldValue)`) will no longer trigger a call to the property getter to fetch the `oldValue`.
@@ -8028,6 +8056,7 @@ Swift 1.0
80288056
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
80298057
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
80308058
[SR-6118]: <https://bugs.swift.org/browse/SR-6118>
8059+
[SR-7083]: <https://bugs.swift.org/browse/SR-7083>
80318060
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
80328061
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
80338062
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>

0 commit comments

Comments
 (0)