Skip to content

Commit 5556700

Browse files
committed
Update CHANGELOG
1 parent c8b6989 commit 5556700

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,42 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0353][]:
9+
10+
Protocols with primary associated types can now be used in existential types,
11+
enabling same-type constraints on those associated types.
12+
13+
```
14+
let strings: any Collection<String> = [ "Hello" ]
15+
```
16+
17+
Note that language features requiring runtime support like dynamic casts
18+
(`is`, `as?`, `as!`), as well as generic usages of parameterized existentials
19+
in generic types (e.g. `Array<any Collection<Int>>`) involve additional
20+
availability checks to use. Back-deploying usages in generic position can be
21+
worked around with a generic type-erasing wrapper struct, which is now much
22+
simpler to implement:
23+
24+
```swift
25+
struct AnyCollection<T> {
26+
var wrapped: any Collection<T>
27+
}
28+
29+
let arrayOfCollections: [AnyCollection<T>] = [ /**/ ]
30+
```
31+
832
* [SE-0329][]:
933
New types representing time and clocks were introduced. This includes a protocol `Clock` defining clocks which allow for defining a concept of now and a way to wake up after a given instant. Additionally a new protocol `InstantProtocol` for defining instants in time was added. Furthermore a new protocol `DurationProtocol` was added to define an elapsed duration between two given `InstantProtocol` types. Most commonly the `Clock` types for general use are the `SuspendingClock` and `ContinuousClock` which represent the most fundamental clocks for the system. The `SuspendingClock` type does not progress while the machine is suspended whereas the `ContinuousClock` progresses no matter the state of the machine.
1034

35+
* [SE-0309][]:
36+
37+
Protocols with associated types and `Self` requirements can now be used as the
38+
types of values with the `any` keyword.
39+
40+
Protocol methods that return associated types can be called on an `any` type;
41+
the result is type-erased to the associated type's upper bound, which is another
42+
`any` type having the same constraints as the associated type. For example:
43+
1144
```swift
1245
func delayedHello() async throws {
1346
try await Task.sleep(until: .now + .milliseconds(123), clock: .continuous)

0 commit comments

Comments
 (0)