Skip to content

Commit 78d2092

Browse files
amartini51ApolloZhu
andcommitted
Iterate on wording
- Keep the "you can" to match other optional bullets - Elevate the "if #available still works" fact Co-authored-by: Apollo Zhu <[email protected]>
1 parent 352a44d commit 78d2092

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

TSPL.docc/ReferenceManual/Attributes.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,8 +1640,9 @@ The additional result-building methods are as follows:
16401640
or to perform other postprocessing on a result before returning it.
16411641

16421642
- term `static func buildLimitedAvailability(_ component: Component) -> Component`:
1643-
Builds a partial result that erases type information for
1644-
outside a compiler-control statement
1643+
Builds a partial result that erases type information.
1644+
You can implement this method to prevent type information
1645+
from propagating outside a compiler-control statement
16451646
that performs an availability check.
16461647

16471648
For example, the code below defines a simple result builder
@@ -1741,9 +1742,14 @@ into code that calls the static methods of the result builder type:
17411742
You can define an overload of `buildExpression(_:)`
17421743
that takes an argument of type `()` to handle assignments specifically.
17431744
- A branch statement that checks an availability condition
1744-
becomes a call to the `buildLimitedAvailability(_:)` method if one is defined.
1745+
becomes a call to the `buildLimitedAvailability(_:)` method,
1746+
if that method is implemented.
1747+
If you don't implement `buildLimitedAvailability(_:)`,
1748+
then branch statements that check availability
1749+
use the same transformations as other branch statements.
17451750
This transformation happens before the transformation into a call to
17461751
`buildEither(first:)`, `buildEither(second:)`, or `buildOptional(_:)`.
1752+
17471753
You use the `buildLimitedAvailability(_:)` method to erase type information
17481754
that changes depending on which branch is taken.
17491755
For example,
@@ -1818,7 +1824,7 @@ into code that calls the static methods of the result builder type:
18181824

18191825
To solve this problem,
18201826
implement a `buildLimitedAvailability(_:)` method
1821-
to erase type information.
1827+
to erase type information by returning a type that's always available.
18221828
For example, the code below builds an `AnyDrawable` value
18231829
from its availability check.
18241830

@@ -1845,11 +1851,6 @@ into code that calls the static methods of the result builder type:
18451851

18461852
<!-- Comment block with swifttest for the code listing above is after the end of this bulleted list, due to tooling limitations. -->
18471853

1848-
Note that the above code compiled before
1849-
implementing the `buildLimitedAvailability` method,
1850-
as its role is not to enable the `if #available` syntax, but to
1851-
return a type that's always available.
1852-
18531854
- A branch statement becomes a series of nested calls to the
18541855
`buildEither(first:)` and `buildEither(second:)` methods.
18551856
The statements' conditions and cases are mapped onto

0 commit comments

Comments
 (0)