Skip to content

Commit 771c1b1

Browse files
authored
Merge pull request #31413 from theblixguy/chore/update-changelog-lazy-observers
[Changelog] Add SR-7083 to the changelog
2 parents 8b52da8 + 636f5ce commit 771c1b1

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
* [SR-11700][]:
3159

3260
Exclusivity violations within code that computes the `default`
@@ -8068,6 +8096,7 @@ Swift 1.0
80688096
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
80698097
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
80708098
[SR-6118]: <https://bugs.swift.org/browse/SR-6118>
8099+
[SR-7083]: <https://bugs.swift.org/browse/SR-7083>
80718100
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
80728101
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
80738102
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>

0 commit comments

Comments
 (0)