You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,42 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
5
5
6
6
## Swift 5.7
7
7
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
+
structAnyCollection<T> {
26
+
var wrapped: anyCollection<T>
27
+
}
28
+
29
+
let arrayOfCollections: [AnyCollection<T>] = [ /**/ ]
30
+
```
31
+
8
32
*[SE-0329][]:
9
33
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.
10
34
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:
0 commit comments