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
[Sema] Require function builders to have at least one buildBlock method #33798
[Sema] Require function builders to have at least one buildBlock method #33798
Conversation
@hborla (or anyone else) would you mind requesting the relevant reviewers? |
I wonder whether it should be allowed to declare a static method in an extension instead of requiring it to be always attached to a type declaration, that might be helpful for file management. After all the requirement is that it buildBlock should exist is vague enough... |
8568db7
to
cdaf54b
Compare
Hm, @xedin could you clarify? I think this check already allows for that (though I just added a test to that effect, see
|
Although, I guess with the support for callable types serving as
|
@Jumhyn The way you made the check makes sense to me, I just wanted to point out that its should be allowed to declare |
cdaf54b
to
6a1e64f
Compare
Gotcha, thank you for clarifying @xedin! I've brought back the check that validates the type of the
This will reject the case I posted above where a non-callable I've also made a small tweak to allow the somewhat-pathological but still syntactically valid:
which can be used as
|
6a1e64f
to
479d75f
Compare
e0dbb68
to
87937e2
Compare
@DougGregor Thank you for the suggestion! I've updated this to share the logic between |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much improved, thank you!
If the supplied method is not static, offer a fix-it to make it static
87937e2
to
b82c57a
Compare
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
Looks like we need to un-XFAIL it. |
I'll just merge, thank you! |
If the supplied method is not static, offer a fix-it to make it static
This is technically source breaking, though AFAICT any function builders which don't have at least one valid
buildBlock
member aren't usable anyway, so maybe okay? If necessary, could downgrade this to a warning.