Skip to content

Commit 07f2e53

Browse files
authored
Merge pull request #27429 from hamishknight/coercion-indirection-changelog
2 parents 75670c1 + f051ac5 commit 07f2e53

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,38 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SR-11429][]:
30+
31+
The compiler will now correctly strip argument labels from function references
32+
used with the `as` operator in a function call. As a result, the `as` operator
33+
can now be used to disambiguate a call to a function with argument labels.
34+
35+
```swift
36+
func foo(x: Int) {}
37+
func foo(x: UInt) {}
38+
39+
(foo as (Int) -> Void)(5) // Calls foo(x: Int)
40+
(foo as (UInt) -> Void)(5) // Calls foo(x: UInt)
41+
```
42+
43+
Previously this was only possible for functions without argument labels.
44+
45+
This change also means that a generic type alias can no longer be used to
46+
preserve the argument labels of a function reference through the `as`
47+
operator. The following is now rejected:
48+
49+
```swift
50+
typealias Magic<T> = T
51+
func foo(x: Int) {}
52+
(foo as Magic)(x: 5) // error: Extraneous argument label 'x:' in call
53+
```
54+
55+
The function value must instead be called without argument labels:
56+
57+
```swift
58+
(foo as Magic)(5)
59+
```
60+
2961
* [SR-11298][]:
3062

3163
A class-constrained protocol extension, where the extended protocol does
@@ -7825,3 +7857,4 @@ Swift 1.0
78257857
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
78267858
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
78277859
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
7860+
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

0 commit comments

Comments
 (0)