|
4 | 4 | > This is in reverse chronological order, so newer entries are added to the top.
|
5 | 5 |
|
6 | 6 | ## 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 | + |
7 | 39 | * [SE-0408][]:
|
8 | 40 | A `for`-`in` loop statement can now accept a pack expansion expression,
|
9 | 41 | enabling iteration over the elements of its respective value pack. This form
|
|
0 commit comments