Skip to content

Commit 024487b

Browse files
committed
Merge remote-tracking branch 'origin/main' into install_embedded_compiler_rt
2 parents 0ca06c2 + 95c4a97 commit 024487b

File tree

4,771 files changed

+218786
-138832
lines changed

Some content is hidden

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

4,771 files changed

+218786
-138832
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ docs/_build
4141
.vs
4242

4343
# clangd
44+
.cache
4445
.clangd
4546

4647
#==============================================================================#

Brewfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
brew "cmake"
22
brew "ninja"
3+
brew "sccache"

CHANGELOG.md

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

77
| Version | Released | Toolchain |
88
| :--------------------- | :--------- | :---------- |
9-
| [Swift 5.3](#swift-53) | | |
9+
| [Swift 5.3](#swift-53) | 2020-09-16 | Xcode 12.0 |
1010
| [Swift 5.2](#swift-52) | 2020-03-24 | Xcode 11.4 |
1111
| [Swift 5.1](#swift-51) | 2019-09-20 | Xcode 11.0 |
1212
| [Swift 5.0](#swift-50) | 2019-03-25 | Xcode 10.2 |
@@ -24,9 +24,165 @@ CHANGELOG
2424

2525
</details>
2626

27-
Swift 5.3
27+
Swift Next
2828
----------
2929

30+
* [SE-0284][]:
31+
32+
Functions, subscripts, and initializers may now have more than one variadic parameter, as long as all parameters which follow variadic parameters are labeled. This makes declarations like the following valid:
33+
34+
```swift
35+
func foo(_ a: Int..., b: Double...) { }
36+
37+
struct Bar {
38+
subscript(a: Int..., b b: Int...) -> [Int] { a + b }
39+
40+
init(a: String..., b: Float...) { }
41+
}
42+
```
43+
44+
* [SE-0287][]:
45+
46+
Implicit member expressions now support chains of member accesses, making the following valid:
47+
48+
```swift
49+
let milky: UIColor = .white.withAlphaComponent(0.5)
50+
let milky2: UIColor = .init(named: "white")!.withAlphaComponent(0.5)
51+
let milkyChance: UIColor? = .init(named: "white")?.withAlphaComponent(0.5)
52+
```
53+
54+
As is the case with the existing implicit member expression syntax, the resulting type of the chain must be the same as the (implicit) base, so it is not well-formed to write:
55+
56+
```swift
57+
let cgMilky: CGColor = .white.withAlphaComponent(0.5).cgColor
58+
```
59+
60+
(Unless, of course, appropriate `white` and `withAlphaComponent` members were defined on `CGColor`.)
61+
62+
Members of a "chain" can be properties, method calls, subscript accesses, force unwraps, or optional chaining question marks. Furthermore, the type of each member along the chain is permitted to differ (again, as long as the base of the chain matches the resulting type) meaning the following successfully typechecks:
63+
64+
```swift
65+
struct Foo {
66+
static var foo = Foo()
67+
static var bar = Bar()
68+
69+
var anotherFoo: Foo { Foo() }
70+
func getFoo() -> Foo { Foo() }
71+
var optionalFoo: Foo? { Foo() }
72+
subscript() -> Foo { Foo() }
73+
}
74+
75+
struct Bar {
76+
var anotherFoo = Foo()
77+
}
78+
79+
let _: Foo? = .bar.anotherFoo.getFoo().optionalFoo?.optionalFoo![]
80+
```
81+
82+
**Add new entries to the top of this section, not here!**
83+
84+
Swift 5.3
85+
---------
86+
87+
### 2020-09-16 (Xcode 12.0)
88+
89+
* [SE-0279][] & [SE-0286][]:
90+
91+
Trailing closure syntax has been extended to allow additional labeled closures to follow the initial unlabeled closure:
92+
93+
```swift
94+
// Single trailing closure argument
95+
UIView.animate(withDuration: 0.3) {
96+
self.view.alpha = 0
97+
}
98+
// Multiple trailing closure arguments
99+
UIView.animate(withDuration: 0.3) {
100+
self.view.alpha = 0
101+
} completion: { _ in
102+
self.view.removeFromSuperview()
103+
}
104+
```
105+
106+
Additionally, trailing closure arguments now match the appropriate parameter according to a forward-scan rule (as opposed to the previous backward-scan rule):
107+
108+
```swift
109+
func takesClosures(first: () -> Void, second: (Int) -> Void = { _ in }) {}
110+
111+
takesClosures {
112+
print("First")
113+
}
114+
```
115+
116+
In the above example, the trailing closure argument matches parameter `first`, whereas pre-Swift-5.3 it would have matched `second`. In order to ease the transition to this new rule, cases in which the forward-scan and backward-scan match a single trailing closure to different parameters, the backward-scan result is preferred and a warning is emitted. This is expected to be upgraded to an error in the next major version of Swift.
117+
118+
* [SR-7083][]:
119+
120+
Property observers such as `willSet` and `didSet` are now supported on `lazy` properties:
121+
122+
```swift
123+
class C {
124+
lazy var property: Int = 0 {
125+
willSet { print("willSet called!") } // Okay
126+
didSet { print("didSet called!") } // Okay
127+
}
128+
}
129+
```
130+
131+
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.
132+
133+
```swift
134+
class C {
135+
lazy var property: Int = 0 {
136+
didSet { print("Old value: ", oldValue) }
137+
}
138+
}
139+
140+
let c = C()
141+
c.property = 1 // Prints 'Old value: 0'
142+
```
143+
144+
This could have side-effects, for example if the lazy property's initializer is doing other work.
145+
146+
* [SR-11700][]:
147+
148+
Exclusivity violations within code that computes the `default`
149+
argument during Dictionary access are now diagnosed.
150+
151+
```swift
152+
struct Container {
153+
static let defaultKey = 0
154+
155+
var dictionary = [defaultKey:0]
156+
157+
mutating func incrementValue(at key: Int) {
158+
dictionary[key, default: dictionary[Container.defaultKey]!] += 1
159+
}
160+
}
161+
// error: overlapping accesses to 'self.dictionary', but modification requires exclusive access; consider copying to a local variable
162+
// dictionary[key, default: dictionary[Container.defaultKey]!] += 1
163+
// ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
164+
// note: conflicting access is here
165+
// dictionary[key, default: dictionary[Container.defaultKey]!] += 1
166+
// ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
167+
```
168+
169+
The exclusivity violation can be avoided by precomputing the `default`
170+
argument using a local variable.
171+
172+
```swift
173+
struct Container {
174+
static let defaultKey = 0
175+
176+
var dictionary = [defaultKey:0]
177+
178+
mutating func incrementValue(at key: Int) {
179+
let defaultValue = dictionary[Container.defaultKey]!
180+
dictionary[key, default: defaultValue] += 1
181+
}
182+
}
183+
// No error.
184+
```
185+
30186
* [SE-0268][]:
31187

32188
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`.
@@ -585,8 +741,6 @@ Swift 5.1
585741
`Array` and `ContiguousArray` now have `init(unsafeUninitializedCapacity:initializingWith:)`,
586742
which provides access to the array's uninitialized storage.
587743

588-
**Add new entries to the top of this section, not here!**
589-
590744
Swift 5.0
591745
---------
592746

@@ -8004,7 +8158,11 @@ Swift 1.0
80048158
[SE-0268]: <https://github.com/apple/swift-evolution/blob/master/proposals/0268-didset-semantics.md>
80058159
[SE-0269]: <https://github.com/apple/swift-evolution/blob/master/proposals/0269-implicit-self-explicit-capture.md>
80068160
[SE-0276]: <https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md>
8161+
[SE-0279]: <https://github.com/apple/swift-evolution/blob/master/proposals/0279-multiple-trailing-closures.md>
80078162
[SE-0280]: <https://github.com/apple/swift-evolution/blob/master/proposals/0280-enum-cases-as-protocol-witnesses.md>
8163+
[SE-0284]: <https://github.com/apple/swift-evolution/blob/master/proposals/0284-multiple-variadic-parameters.md>
8164+
[SE-0286]: <https://github.com/apple/swift-evolution/blob/master/proposals/0286-forward-scan-trailing-closures.md>
8165+
[SE-0287]: <https://github.com/apple/swift-evolution/blob/master/proposals/0287-implicit-member-chains.md>
80088166

80098167
[SR-75]: <https://bugs.swift.org/browse/SR-75>
80108168
[SR-106]: <https://bugs.swift.org/browse/SR-106>
@@ -8028,6 +8186,7 @@ Swift 1.0
80288186
[SR-5581]: <https://bugs.swift.org/browse/SR-5581>
80298187
[SR-5719]: <https://bugs.swift.org/browse/SR-5719>
80308188
[SR-6118]: <https://bugs.swift.org/browse/SR-6118>
8189+
[SR-7083]: <https://bugs.swift.org/browse/SR-7083>
80318190
[SR-7139]: <https://bugs.swift.org/browse/SR-7139>
80328191
[SR-7251]: <https://bugs.swift.org/browse/SR-7251>
80338192
[SR-7601]: <https://bugs.swift.org/browse/SR-7601>
@@ -8039,4 +8198,5 @@ Swift 1.0
80398198
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
80408199
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
80418200
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>
8201+
[SR-11700]: <https://bugs.swift.org/browse/SR-11700>
80428202
[SR-11841]: <https://bugs.swift.org/browse/SR-11841>

0 commit comments

Comments
 (0)