Skip to content

[CS] Improve diagnostics when buildPartialBlock is unavailable #60803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

hamishknight
Copy link
Contributor

If buildBlock is also unavailable, or the builder itself is unavailable, continue to solve using buildPartialBlock to get better diagnostics.

This behavior technically differs from what is specified in SE-0348, but only affects the invalid case where no builder methods are available to use.

In particular, this improves diagnostics for RegexComponentBuilder when the deployment target is too low. Previously we would try to solve using buildBlock (as buildPartialBlock is unavailable), but RegexComponentBuilder only defines buildBlock for the empty body case, leading to unhelpful diagnostics that ultimately preferred not to use the result builder at all.

rdar://97533700

Previously we would cache the result of the first
query, with any further query of
`ResultBuilder::supports` ignoring the
`checkAvailability` parameter. Separate out the
availability checking such that we compute the
information up front, and adjust the result
depending on `checkAvailability`.
If `buildBlock` is also unavailable, or the
builder itself is unavailable, continue to solve
using `buildPartialBlock` to get better
diagnostics.

This behavior technically differs from what is
specified in SE-0348, but only affects the invalid
case where no builder methods are available to use.

In particular, this improves diagnostics for
RegexComponentBuilder when the deployment target
is too low. Previously we would try to solve using
`buildBlock` (as `buildPartialBlock` is unavailable),
but RegexComponentBuilder only defines `buildBlock`
for the empty body case, leading to unhelpful
diagnostics that ultimately preferred not to use
the result builder at all.

rdar://97533700
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

@hamishknight hamishknight requested review from xedin and rxwei August 26, 2022 18:59
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit db2a9a4 into swiftlang:main Aug 31, 2022
@hamishknight hamishknight deleted the part-and-partial branch August 31, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants