NFC: Add a changelog entry for SE-0376.

This commit is contained in:
Allan Shortlidge
2023-02-01 22:03:31 -08:00
parent 022abe4d3b
commit d44c9f2ccc
2 changed files with 29 additions and 11 deletions

View File

@@ -4,6 +4,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
## Swift 5.8
* [SE-0376][]:
The `@backDeployed(before:)` attribute may now be used to extend the availability of a function to OS releases prior to the introduction of that function as ABI.
For example, suppose that `struct Temperature` was introduced in a macOS SDK framework in macOS 12. Later in macOS 13 the framework authors decided to add a `degreesFahrenheit` property as a convenience:
```swift
@available(macOS 12, *)
public struct Temperature {
public var degreesCelsius: Double
// ...
}
extension Temperature {
@available(macOS 12, *)
@backDeployed(before: macOS 13)
public var degreesFahrenheit: Double {
return (degreesCelsius * 9 / 5) + 32
}
}
```
Adding the `@backDeployed` attribute to `degreesFahrenheit` enables the framework author to make this new declaration available to apps with a minimum deployment target of macOS 12, even though the ABI entry point for `degreesFahrenheit` is only present in macOS 13 and up.
When a function with `@backDeployed` is called, the compiler wraps the invocation of the function in a thunk. The thunk checks whether the library entry point for the declaration is available at runtime, and invokes it if it is. Otherwise, a copy of the function that was emitted into the client is called instead.
* [#56139][]:
Сollection downcasts in cast patterns are now supported. For example:
@@ -9611,6 +9638,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
[SE-0365]: <https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md>
[SE-0370]: <https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
[SE-0376]: <https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
[#42697]: <https://github.com/apple/swift/issues/42697>
[#42728]: <https://github.com/apple/swift/issues/42728>

View File

@@ -53,17 +53,7 @@ Adding this attribute to a type leads to remarks being emitted for all methods.
## `@_backDeploy(before: ...)`
Causes the body of a function to be emitted into the module interface to be
available for emission into clients with deployment targets lower than the
ABI availability of the function. When the client's deployment target is
before the function's ABI availability, the compiler replaces calls to that
function with a call to a thunk that checks at runtime whether the original
library function is available. If the original is available then it is
called. Otherwise, the fallback copy of the function that was emitted into the
client is called instead.
For more details, see the [pitch thread](https://forums.swift.org/t/pitch-function-back-deployment/55769/)
in the forums.
The spelling of `@backDeployed(before:)` prior to the acceptance of [SE-0376](https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md).
## `@_borrowed`