Skip to content

Commit 45661f6

Browse files
committed
Merge branch 'master' into RemoveRedundantBufferZeroingNSStringAPI
2 parents 9c7624c + 99e4918 commit 45661f6

File tree

1,250 files changed

+26563
-16214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,250 files changed

+26563
-16214
lines changed

CHANGELOG.md

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,75 @@ CHANGELOG
2525
</details>
2626

2727
Swift 5.3
28-
----------
28+
---------
29+
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+
58+
* [SR-11700][]:
59+
60+
Exclusivity violations within code that computes the `default`
61+
argument during Dictionary access are now diagnosed.
62+
63+
```swift
64+
struct Container {
65+
static let defaultKey = 0
66+
67+
var dictionary = [defaultKey:0]
68+
69+
mutating func incrementValue(at key: Int) {
70+
dictionary[key, default: dictionary[Container.defaultKey]!] += 1
71+
}
72+
}
73+
// error: overlapping accesses to 'self.dictionary', but modification requires exclusive access; consider copying to a local variable
74+
// dictionary[key, default: dictionary[Container.defaultKey]!] += 1
75+
// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76+
// note: conflicting access is here
77+
// dictionary[key, default: dictionary[Container.defaultKey]!] += 1
78+
// ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
79+
```
80+
81+
The exclusivity violation can be avoided by precomputing the `default`
82+
argument using a local variable.
83+
84+
```swift
85+
struct Container {
86+
static let defaultKey = 0
87+
88+
var dictionary = [defaultKey:0]
89+
90+
mutating func incrementValue(at key: Int) {
91+
let defaultValue = dictionary[Container.defaultKey]!
92+
dictionary[key, default: defaultValue] += 1
93+
}
94+
}
95+
// No error.
96+
```
2997

3098
* [SE-0268][]:
3199

@@ -585,8 +653,6 @@ Swift 5.1
585653
`Array` and `ContiguousArray` now have `init(unsafeUninitializedCapacity:initializingWith:)`,
586654
which provides access to the array's uninitialized storage.
587655

588-
**Add new entries to the top of this section, not here!**
589-
590656
Swift 5.0
591657
---------
592658

@@ -8028,6 +8094,7 @@ Swift 1.0
80288094
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
80298095
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
80308096
[SR-6118]: <https://bugs.swift.org/browse/SR-6118>
8097+
[SR-7083]: <https://bugs.swift.org/browse/SR-7083>
80318098
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
80328099
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
80338100
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>
@@ -8039,4 +8106,5 @@ Swift 1.0
80398106
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
80408107
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
80418108
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>
8109+
[SR-11700]: <https://bugs.swift.org/browse/SR-11700>
80428110
[SR-11841]: <https://bugs.swift.org/browse/SR-11841>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ See [docs/Testing.md](docs/Testing.md), in particular the section on [lit.py](do
338338

339339
Be sure to look through the [docs](https://github.com/apple/swift/tree/master/docs)
340340
directory for more information about the compiler. In particular, the documents
341-
titled [Debugging the Swift Compiler](docs/DebuggingTheCompiler.rst) and
341+
titled [Debugging the Swift Compiler](docs/DebuggingTheCompiler.md) and
342342
[Continuous Integration for Swift](docs/ContinuousIntegration.md) are very
343343
helpful to understand before submitting your first PR.
344344

benchmark/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ set(SWIFT_BENCH_MODULES
9797
single-source/Hash
9898
single-source/Histogram
9999
single-source/HTTP2StateMachine
100+
single-source/InsertCharacter
101+
single-source/IntegerParsing
100102
single-source/Integrate
101103
single-source/IterateData
102104
single-source/Join

benchmark/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ The following build options are available:
7474
The following build targets are available:
7575

7676
* `swift-benchmark-macosx-x86_64`
77+
* `swift-benchmark-iphoneos-arm64e`
7778
* `swift-benchmark-iphoneos-arm64`
7879
* `swift-benchmark-iphoneos-armv7`
7980
* `swift-benchmark-appletvos-arm64`

benchmark/utils/main.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ import Hanoi
8585
import Hash
8686
import Histogram
8787
import HTTP2StateMachine
88+
import InsertCharacter
89+
import IntegerParsing
8890
import Integrate
8991
import IterateData
9092
import Join
@@ -268,6 +270,8 @@ registerBenchmark(Hanoi)
268270
registerBenchmark(HashTest)
269271
registerBenchmark(Histogram)
270272
registerBenchmark(HTTP2StateMachine)
273+
registerBenchmark(InsertCharacter)
274+
registerBenchmark(IntegerParsing)
271275
registerBenchmark(IntegrateTest)
272276
registerBenchmark(IterateData)
273277
registerBenchmark(Join)

0 commit comments

Comments
 (0)