Skip to content

Commit 1344df3

Browse files
authored
Merge pull request #59253 from slavapestov/update-changelog-se-0353
Update changelog entry for SE-0353
2 parents a01e1b8 + 6a394c5 commit 1344df3

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

CHANGELOG.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
112112

113113
* [SE-0346][]:
114114

115-
Protocols can now declare a list of one or more primary associated types:
115+
Protocols can now declare a list of one or more _primary associated types_, which enable writing same-type requirements on those associated types using angle bracket syntax:
116116

117117
```swift
118118
protocol Graph<Vertex, Edge> {
@@ -121,31 +121,30 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
121121
}
122122
```
123123

124-
A protocol-constrained type like `Graph<Int>` can now be written anywhere that
125-
expects the right-hand side of a protocol conformance requirement:
124+
You can now write a protocol name followed by type arguments in angle brackets, like
125+
`Graph<Int, String>`, anywhere that a protocol conformance requirement may appear:
126126

127127
```swift
128-
func shortestPath<V, E>(_: some Graph<V>, from: V, to: V) -> [E]
128+
func shortestPath<V, E>(_: some Graph<V, E>, from: V, to: V) -> [E]
129129

130-
extension Graph<Int> {...}
130+
extension Graph<Int, String> {...}
131131

132-
func build() -> some Graph<String> {}
132+
func build() -> some Graph<Int, String> {}
133133
```
134134

135-
A protocol-constrained type is equivalent to a conformance requirement to the protocol
136-
itself together with a same-type requirement constraining the primary associated type.
135+
A protocol name followed by angle brackets is shorthand for a conformance requirement,
136+
together with a same-type requirement for the protocol's primary associated types.
137137
The first two examples above are equivalent to the following:
138138

139139
```swift
140140
func shortestPath<V, E, G>(_: G, from: V, to: V) -> [E]
141-
where G: Graph, G.Vertex == V, G.Edge == V
141+
where G: Graph, G.Vertex == V, G.Edge == E
142142

143-
extension Graph where Vertex == Int {...}
143+
extension Graph where Vertex == Int, Edge == String {...}
144144
```
145145

146-
The `build()` function returning `some Graph<String>` cannot be written using a `where`
147-
clause; this is an example of a constrained opaque result type, which could not be written
148-
before.
146+
The `build()` function returning `some Graph<Int, String>` can't be written using a
147+
`where` clause; this is an example of a constrained opaque result type, which is new expressivity in Swift 5.7.
149148

150149
* [SE-0353][]:
151150

0 commit comments

Comments
 (0)