Skip to content

Commit 8ab196b

Browse files
authored
Merge pull request #41073 from DougGregor/changelog-updates-5.6
Changelog updates 5.6
2 parents d430b3e + db2341a commit 8ab196b

File tree

1 file changed

+111
-1
lines changed

1 file changed

+111
-1
lines changed

CHANGELOG.md

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,104 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
66
Swift 5.6
77
---------
88

9+
* [SE-0335][]:
10+
11+
Swift now allows existential types to be explicitly written with the `any`
12+
keyword, creating a syntactic distinction between existential types and
13+
protocol conformance constraints. For example:
14+
15+
```swift
16+
protocol P {}
17+
18+
func generic<T>(value: T) where T: P {
19+
...
20+
}
21+
22+
func existential(value: any P) {
23+
...
24+
}
25+
```
26+
27+
* [SE-0337][]:
28+
29+
Swift now provides an incremental migration path to data race safety, allowing
30+
APIs to adopt concurrency without breaking their clients that themselves have
31+
not adopted concurrency. An existing declaration can introduce
32+
concurrency-related annotations (such as making its closure parameters
33+
`@Sendable`) and use the `@preconcurrency` attribute to maintain its behavior
34+
for clients who have not themselves adopted concurrency:
35+
36+
```swift
37+
// module A
38+
@preconcurrency func runOnSeparateTask(_ workItem: @Sendable () -> Void)
39+
40+
// module B
41+
import A
42+
43+
class MyCounter {
44+
var value = 0
45+
}
46+
47+
func doesNotUseConcurrency(counter: MyCounter) {
48+
runOnSeparateTask {
49+
counter.value += 1 // no warning, because this code hasn't adopted concurrency
50+
}
51+
}
52+
53+
func usesConcurrency(counter: MyCounter) async {
54+
runOnSeparateTask {
55+
counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
56+
}
57+
}
58+
```
59+
60+
One can enable warnings about data race safety within a module with the
61+
`-warn-concurrency` compiler option. When using a module that does not yet
62+
provide `Sendable` annotations, one can suppress warnings for types from that
63+
module by marking the import with `@preconcurrency`:
64+
65+
```swift
66+
/// module C
67+
public struct Point {
68+
public var x, y: Double
69+
}
70+
71+
// module D
72+
@preconcurrency import C
73+
74+
func centerView(at location: Point) {
75+
Task {
76+
await mainView.center(at: location) // no warning about non-Sendable 'Point' because the @preconcurrency import suppresses it
77+
}
78+
}
79+
```
80+
81+
* [SE-0302][]:
82+
83+
Swift will now produce warnings to indicate potential data races when
84+
non-`Sendable` types are passed across actor or task boundaries. For
85+
example:
86+
87+
```swift
88+
class MyCounter {
89+
var value = 0
90+
}
91+
92+
func f() -> MyCounter {
93+
let counter = MyCounter()
94+
Task {
95+
counter.value += 1 // warning: capture of non-Sendable type 'MyCounter'
96+
}
97+
return counter
98+
}
99+
```
100+
101+
* [SE-0331][]:
102+
103+
The conformance of the unsafe pointer types (e.g., `UnsafePointer`,
104+
`UnsafeMutableBufferPointer`) to the `Sendable` protocols has been removed,
105+
because pointers cannot safely be transferred across task or actor boundaries.
106+
9107
* References to `Self` or so-called "`Self` requirements" in the type signatures
10108
of protocol members are now correctly detected in the parent of a nested type.
11109
As a result, protocol members that fall under this overlooked case are no longer
@@ -26,7 +124,7 @@ Swift 5.6
26124
// protocol type (use a generic constraint instead).
27125
_ = p.method
28126
}
29-
```
127+
```
30128

31129
* [SE-0324][]:
32130

@@ -53,6 +151,13 @@ Swift 5.6
53151
}
54152
```
55153

154+
* [SE-0322][]:
155+
156+
The standard library now provides a new operation
157+
`withUnsafeTemporaryAllocation` which provides an efficient temporarily
158+
allocation within a limited scope, which will be optimized to use stack
159+
allocation when possible.
160+
56161
* [SE-0315][]:
57162

58163
Type expressions and annotations can now include "type placeholders" which
@@ -8753,14 +8858,19 @@ Swift 1.0
87538858
[SE-0298]: <https://github.com/apple/swift-evolution/blob/main/proposals/0298-asyncsequence.md>
87548859
[SE-0299]: <https://github.com/apple/swift-evolution/blob/main/proposals/0299-extend-generic-static-member-lookup.md>
87558860
[SE-0300]: <https://github.com/apple/swift-evolution/blob/main/proposals/0300-continuation.md>
8861+
[SE-0302]: <https://github.com/apple/swift-evolution/blob/main/proposals/0302-concurrent-value-and-concurrent-closures.md>
87568862
[SE-0306]: <https://github.com/apple/swift-evolution/blob/main/proposals/0306-actors.md>
87578863
[SE-0310]: <https://github.com/apple/swift-evolution/blob/main/proposals/0310-effectful-readonly-properties.md>
87588864
[SE-0311]: <https://github.com/apple/swift-evolution/blob/main/proposals/0311-task-locals.md>
87598865
[SE-0313]: <https://github.com/apple/swift-evolution/blob/main/proposals/0313-actor-isolation-control.md>
87608866
[SE-0315]: <https://github.com/apple/swift-evolution/blob/main/proposals/0315-placeholder-types.md>
87618867
[SE-0316]: <https://github.com/apple/swift-evolution/blob/main/proposals/0316-global-actors.md>
8868+
[SE-0322]: <https://github.com/apple/swift-evolution/blob/main/proposals/0322-temporary-buffers.md>
87628869
[SE-0324]: <https://github.com/apple/swift-evolution/blob/main/proposals/0324-c-lang-pointer-arg-conversion.md>
87638870
[SE-0323]: <https://github.com/apple/swift-evolution/blob/main/proposals/0323-async-main-semantics.md>
8871+
[SE-0331]: <https://github.com/apple/swift-evolution/blob/main/proposals/0331-remove-sendable-from-unsafepointer.md>
8872+
[SE-0337]: <https://github.com/apple/swift-evolution/blob/main/proposals/0337-support-incremental-migration-to-concurrency-checking.md>
8873+
[SE-0335]: <https://github.com/apple/swift-evolution/blob/main/proposals/0335-existential-any.md>
87648874

87658875
[SR-75]: <https://bugs.swift.org/browse/SR-75>
87668876
[SR-106]: <https://bugs.swift.org/browse/SR-106>

0 commit comments

Comments
 (0)