Skip to content

Commit f8d8005

Browse files
authored
[Changelog] Add entries for SE-0279 and SE-0286 (swiftlang#33729)
1 parent 3c5322d commit f8d8005

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@ Swift Next
6969
Swift 5.3
7070
---------
7171

72+
* [SE-0279][] & [SE-0286][]:
73+
74+
Trailing closure syntax has been extended to allow additional labeled closures to follow the initial unlabeled closure:
75+
76+
```swift
77+
// Single trailing closure argument
78+
UIView.animate(withDuration: 0.3) {
79+
self.view.alpha = 0
80+
}
81+
// Multiple trailing closure arguments
82+
UIView.animate(withDuration: 0.3) {
83+
self.view.alpha = 0
84+
} completion: { _ in
85+
self.view.removeFromSuperview()
86+
}
87+
```
88+
89+
Additionally, trailing closure arguments now match the appropriate parameter according to a forward-scan rule (as opposed to the previous backward-scan rule):
90+
91+
```swift
92+
func takesClosures(first: () -> Void, second: (Int) -> Void = { _ in }) {}
93+
94+
takesClosures {
95+
print("First")
96+
}
97+
```
98+
99+
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.
100+
72101
* [SR-7083][]:
73102

74103
Property observers such as `willSet` and `didSet` are now supported on `lazy` properties:
@@ -8112,7 +8141,9 @@ Swift 1.0
81128141
[SE-0268]: <https://github.com/apple/swift-evolution/blob/master/proposals/0268-didset-semantics.md>
81138142
[SE-0269]: <https://github.com/apple/swift-evolution/blob/master/proposals/0269-implicit-self-explicit-capture.md>
81148143
[SE-0276]: <https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md>
8144+
[SE-0279]: <https://github.com/apple/swift-evolution/blob/master/proposals/0279-multiple-trailing-closures.md>
81158145
[SE-0280]: <https://github.com/apple/swift-evolution/blob/master/proposals/0280-enum-cases-as-protocol-witnesses.md>
8146+
[SE-0286]: <https://github.com/apple/swift-evolution/blob/master/proposals/0286-forward-scan-trailing-closures.md>
81168147
[SE-0287]: <https://github.com/apple/swift-evolution/blob/master/proposals/0287-implicit-member-chains.md>
81178148

81188149
[SR-75]: <https://bugs.swift.org/browse/SR-75>

0 commit comments

Comments
 (0)