-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Function builders] Add support for buildExpression(). #27716
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
[Function builders] Add support for buildExpression(). #27716
Conversation
If a function builder type has a static method buildExpression(), use it to pass through each expression whose value will become part of the final result. This is part of the function builders pitch that had not yet been implemented.
@swift-ci please smoke test |
@swift-ci please test compiler performance |
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.
So, the real blocker for buildExpression
is that we need to transform single-expression closures, but this is certainly a necessary step and generally looks right to me.
if (builderSupports(ctx.Id_buildExpression)) { | ||
expr = buildCallIfWanted(expr->getLoc(), ctx.Id_buildExpression, | ||
{ expr }, { Identifier() }, | ||
/*allowOneWay=*/true); |
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.
I know the parameter name is existing code, but why is this "allow" one-way, since it's an unconditional instruction to make the result one-way?
Anyway, this seems like the right interaction with one-way, although arguably it would be clearer in code if that was done unconditionally as a separate step.
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.
It used to be conditional, and I just removed the staging flag. I can clean this up
@xedin is going to look into single-expression closures. We need to delay constraint generation for single-expression closures until we know which parameter it will get matched with. |
If a function builder type has a static method buildExpression(), use
it to pass through each expression whose value will become part of the
final result. This is part of the function builders pitch that had not
yet been implemented.