Skip to content

Commit 5b1b1f5

Browse files
Update recent changelog entry to mention an edge-case source break
1 parent 9857464 commit 5b1b1f5

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
177177
For example, this allows writing down the types `some Collection<Int>` and
178178
`any Collection<Int>`.
179179

180-
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on the `AnyObject` metatype are now supported. These references always have the type of a function that accepts a single argument and returns an optional value of function type:
180+
* References to `optional` methods on a protocol metatype, as well as references to dynamically looked up methods on `AnyObject` are now supported on par with other function references. The type of such a reference (formerly an immediate optional by mistake) has been altered to that of a function that takes a single argument and returns an optional value of function type:
181181

182182
```swift
183183
class Object {
184-
@objc func getTag() -> Int
184+
@objc func getTag() -> Int { ... }
185185
}
186186

187-
@objc protocol P {
187+
let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag
188+
189+
@objc protocol Delegate {
188190
@objc optional func didUpdateObject(withTag tag: Int)
189191
}
190192

191-
let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag
192-
193-
let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
193+
let didUpdateObjectWithTag: (Delegate) -> ((Int) -> Void)? = Delegate.didUpdateObject
194194
```
195195

196+
> **Warning**
197+
> Due to the type change, selectors for aforementioned method references that require writing out their type explicitly for disambiguation will no longer compile. To fix this, simply adjust the written type, or resort to a `#if swift(<5.7)` directive when compatibility with older compiler versions is warranted. For example:
198+
>
199+
> ```swift
200+
> #if swift(<5.7)
201+
> let decidePolicyForNavigationAction = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as ((WKNavigationDelegate) -> (WKWebView, WKNavigationAction, @escaping (WKNavigationActionPolicy) -> Void) -> Void)?)
202+
> #else
203+
> let decidePolicyForNavigationAction = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as (WKNavigationDelegate) -> ((WKWebView, WKNavigationAction, @escaping (WKNavigationActionPolicy) -> Void) -> Void)?)
204+
> #endif
205+
> ```
206+
196207
* [SE-0349][]:
197208
198209
Loading data from raw memory represented by `UnsafeRawPointer`,

0 commit comments

Comments
 (0)