Skip to content

Commit 582ec11

Browse files
committed
Document two minor source-breaking bug fixes in Swift 6.0
1 parent b9df9a7 commit 582ec11

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,38 @@
44
> This is in reverse chronological order, so newer entries are added to the top.
55
66
## Swift 6.0
7+
8+
* Swift 5.10 missed a semantic check from [SE-0309][]. In type context, a reference to a
9+
protocol `P` that has associated types or `Self` requirements should use
10+
the `any` keyword, but this was not enforced in nested generic argument positions.
11+
This is now an error as required by the proposal:
12+
13+
```swift
14+
protocol P { associatedtype A }
15+
struct Outer<T> { struct Inner<U> { } }
16+
let x = Outer<P>.Inner<P>() // error
17+
```
18+
To correct the error, add `any` where appropriate, for example
19+
`Outer<any P>.Inner<any P>`.
20+
21+
* Swift 5.10 accepted certain invalid opaque return types from [SE-0346][].
22+
If a generic argument of a constrained opaque return type did not
23+
satisfy the requirements on the primary associated type, the generic
24+
argument was silently ignored and type checking would proceed as if it
25+
weren't stated. This now results in a diagnostic:
26+
27+
```swift
28+
protocol P<A> { associatedtype A: Sequence }
29+
struct G<A: Sequence>: P {}
30+
31+
func f() -> some P<Int> { return G<Array<Int>>() } // error
32+
```
33+
34+
The return type above should be written as `some P<Array<Int>>` to match
35+
the return statement. The old broken behavior in this situation can also
36+
be restored, by removing the erroneous constraint and using the more general
37+
upper bound `some P`.
38+
739
* [SE-0408][]:
840
A `for`-`in` loop statement can now accept a pack expansion expression,
941
enabling iteration over the elements of its respective value pack. This form

0 commit comments

Comments
 (0)