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
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`.
0 commit comments