Skip to content

Commit d44c9f2

Browse files
committed
NFC: Add a changelog entry for SE-0376.
1 parent 022abe4 commit d44c9f2

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
44

55
## Swift 5.8
66

7+
* [SE-0376][]:
8+
9+
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.
10+
11+
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:
12+
13+
```swift
14+
@available(macOS 12, *)
15+
public struct Temperature {
16+
public var degreesCelsius: Double
17+
18+
// ...
19+
}
20+
21+
extension Temperature {
22+
@available(macOS 12, *)
23+
@backDeployed(before: macOS 13)
24+
public var degreesFahrenheit: Double {
25+
return (degreesCelsius * 9 / 5) + 32
26+
}
27+
}
28+
```
29+
30+
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.
31+
32+
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.
33+
734
* [#56139][]:
835

936
С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
96119638
[SE-0362]: <https://github.com/apple/swift-evolution/blob/main/proposals/0362-piecemeal-future-features.md>
96129639
[SE-0365]: <https://github.com/apple/swift-evolution/blob/main/proposals/0365-implicit-self-weak-capture.md>
96139640
[SE-0370]: <https://github.com/apple/swift-evolution/blob/main/proposals/0370-pointer-family-initialization-improvements.md>
9641+
[SE-0376]: <https://github.com/apple/swift-evolution/blob/main/proposals/0376-function-back-deployment.md>
96149642

96159643
[#42697]: <https://github.com/apple/swift/issues/42697>
96169644
[#42728]: <https://github.com/apple/swift/issues/42728>

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,7 @@ Adding this attribute to a type leads to remarks being emitted for all methods.
5353

5454
## `@_backDeploy(before: ...)`
5555

56-
Causes the body of a function to be emitted into the module interface to be
57-
available for emission into clients with deployment targets lower than the
58-
ABI availability of the function. When the client's deployment target is
59-
before the function's ABI availability, the compiler replaces calls to that
60-
function with a call to a thunk that checks at runtime whether the original
61-
library function is available. If the original is available then it is
62-
called. Otherwise, the fallback copy of the function that was emitted into the
63-
client is called instead.
64-
65-
For more details, see the [pitch thread](https://forums.swift.org/t/pitch-function-back-deployment/55769/)
66-
in the forums.
56+
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).
6757

6858
## `@_borrowed`
6959

0 commit comments

Comments
 (0)