Skip to content

Commit 1ec678e

Browse files
committed
Update CHANGELOG
1 parent 663722d commit 1ec678e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,26 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
7272

7373
* [SE-0353][]:
7474

75-
Further generalizing the above, protocol-constrained types can also be used with `any`:
75+
Protocols with primary associated types can now be used in existential types,
76+
enabling same-type constraints on those associated types.
77+
78+
```
79+
let strings: any Collection<String> = [ "Hello" ]
80+
```
81+
82+
Note that language features requiring runtime support like dynamic casts
83+
(`is`, `as?`, `as!`), as well as generic usages of parameterized existentials
84+
in generic types (e.g. `Array<any Collection<Int>>`) involve additional
85+
availability checks to use. Back-deploying usages in generic position can be
86+
worked around with a generic type-erasing wrapper struct, which is now much
87+
simpler to implement:
7688

7789
```swift
78-
func findBestGraph(_: [any Graph<Int>]) -> any Graph<Int> {...}
90+
struct AnyCollection<T> {
91+
var wrapped: any Collection<T>
92+
}
93+
94+
let arrayOfCollections: [AnyCollection<T>] = [ /**/ ]
7995
```
8096

8197
* [SE-0358][]:

0 commit comments

Comments
 (0)