Skip to content

Commit ce18dd1

Browse files
committed
Update CHANGELOG
1 parent 663722d commit ce18dd1

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

CHANGELOG.md

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

66
## Swift 5.7
77

8+
```
9+
810
* [SE-0309][]:
911
1012
Protocols with associated types and `Self` requirements can now be used as the
@@ -72,11 +74,26 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
7274

7375
* [SE-0353][]:
7476

75-
Further generalizing the above, protocol-constrained types can also be used with `any`:
77+
Protocols with primary associated types can now be used in existential types,
78+
enabling same-type constraints on those associated types.
7679

77-
```swift
78-
func findBestGraph(_: [any Graph<Int>]) -> any Graph<Int> {...}
7980
```
81+
let strings: any Collection<String> = [ "Hello" ]
82+
```
83+
84+
Note that language features requiring runtime support like dynamic casts
85+
(`is`, `as?`, `as!`), as well as generic usages of parameterized existentials
86+
in generic types (e.g. `Array<any Collection<Int>>`) involve additional
87+
availability checks to use. Back-deploying usages in generic position can be
88+
worked around with a generic type-erasing wrapper struct, which is now much
89+
simpler to implement:
90+
91+
```swift
92+
struct AnyCollection<T> {
93+
var wrapped: any Collection<T>
94+
}
95+
96+
let arrayOfCollections: [AnyCollection<T>] = [ /**/ ]
8097

8198
* [SE-0358][]:
8299

0 commit comments

Comments
 (0)