-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Emphasize type erasure in buildLimitedAvailability (#320)
A common misconception that people have about `buildLimitedAvailability` is that it enables the following syntax in result builders: ```swift @DrawingBuilder var x: Drawable { if #available(macOS 99, *) { FutureText("Inside.future") } else { Text("Inside.present") } } ``` and would implement `buildLimitedAvailability` as follows: ```swift static func buildLimitedAvailability(component: some Drawable) -> some Drawable { component } ``` However, the above code will still result in a crash in an earlier OS where `FutureText` is not available. This change calls out the importance and need to perform type erasure in `buildLimitedAvailability`.
- Loading branch information
Showing
1 changed file
with
12 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters