You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,33 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
4
4
5
5
## Swift 5.8
6
6
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(macOS12, *)
15
+
publicstructTemperature {
16
+
publicvar degreesCelsius: Double
17
+
18
+
// ...
19
+
}
20
+
21
+
extensionTemperature {
22
+
@available(macOS12, *)
23
+
@backDeployed(before: macOS 13)
24
+
publicvar 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
+
7
34
*[#56139][]:
8
35
9
36
С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
Copy file name to clipboardExpand all lines: docs/ReferenceGuides/UnderscoredAttributes.md
+1-11Lines changed: 1 addition & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -53,17 +53,7 @@ Adding this attribute to a type leads to remarks being emitted for all methods.
53
53
54
54
## `@_backDeploy(before: ...)`
55
55
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).
0 commit comments