Skip to content

🍒 [5.7] Update recent changelog entry to mention an edge-case source break #59362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
}
```

* 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:
* 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:

```swift
class Object {
@objc func getTag() -> Int
@objc func getTag() -> Int { ... }
}

@objc protocol P {
let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag

@objc protocol Delegate {
@objc optional func didUpdateObject(withTag tag: Int)
}

let getTag: (AnyObject) -> (() -> Int)? = AnyObject.getTag

let didUpdateObject: (any P) -> ((Int) -> Void)? = P.didUpdateObject
let didUpdateObjectWithTag: (Delegate) -> ((Int) -> Void)? = Delegate.didUpdateObject
```

> **Warning**
> 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:
>
> ```swift
> #if swift(<5.7)
> let decidePolicyForNavigationAction = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as ((WKNavigationDelegate) -> (WKWebView, WKNavigationAction, @escaping (WKNavigationActionPolicy) -> Void) -> Void)?)
> #else
> let decidePolicyForNavigationAction = #selector(WKNavigationDelegate.webView(_:decidePolicyFor:decisionHandler:) as (WKNavigationDelegate) -> ((WKWebView, WKNavigationAction, @escaping (WKNavigationActionPolicy) -> Void) -> Void)?)
> #endif
> ```

* [SE-0349][]:

Loading data from raw memory represented by `UnsafeRawPointer`,
Expand Down