-
Notifications
You must be signed in to change notification settings - Fork 470
Add ProtocolDecl test cases
#356
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
Conversation
502da19 to
6dd0e74
Compare
|
@swift-ci please test |
ahoppen
left a comment
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.
Some minor comments, otherwise LGTM.
| let returnClause = ArrayType(elementType: "DeclSyntax") | ||
| let input = ParameterClause(parameterListBuilder: { | ||
| FunctionParameter(firstName: .identifier("format"), colon: .colon, type: "Format", trailingComma: .comma, attributesBuilder: {}) | ||
| FunctionParameter(firstName: .identifier("leadingTrivia"), colon: .colon, type: OptionalType(wrappedType: "Trivia"), attributesBuilder: {}) |
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.
Is the attributesBuilder argument necessary? Shouldn’t it be defaulted?
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 should yes.
But the problem is that we then get Ambiguous use of 'init'.
I think we should, somehow, solve this as there is many init methods that look like each other so we need to do things like this to avoid the error. It works now, but I think it makes some noice/cluttered code when using it.
This is a long shot, and I'm not sure if it is technically possible, but I'll try to explain.
It would be nice if we could remove this type of init methods, where the convenience init method only have builders as different as the non-convenience init.
Like the one here: https://github.com/apple/swift-syntax/blob/caa735a5a5c41f4fc1769e5c34bb2cde17157400/Sources/SwiftSyntaxBuilder/gyb_generated/BuildableNodes.swift#L5676-L5721
This will mean, in this case, that our AttributeListBuilder need to conform to ExpressibleAsAttributeList.
And then we could things like FunctionParameter(modifiers: { TokenSyntax.public }, firstName: .identifier("format"), colon: .colon, type: "Format", trailingComma: .comma) or
FunctionParameter(modifiers: TokenSyntax.public, firstName: .identifier("format"), colon: .colon, type: "Format", trailingComma: .comma).
I think we before have talked about that the @resultBuilders should conform to some of the protocols.
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 see, makes sense 👍 I’m good with merging this as-is.
As to your other question:
If I understand you correctly, you are saying that you’d like to remove the second initializer listed in the code snippet and make AttributeListBuilder conform to ExpressibleAsAttributeList. In that case you expect to be able to use the AttributeListBuilder result builder wherever an ExpressibleAsAttributeList is expected, right?
If this is what you’re suggesting, I’m pretty sure it won’t work. I think the result builder needs to be declared using @AttributeListBuilder on the parameter or otherwise the type checker won’t try to apply it.
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.
Okay! Thanks, than it is this way :)
Did you see my question here too:
#356 (comment)
6dd0e74 to
5f01be6
Compare
|
@swift-ci please test |
|
Build failed |
|
Another question @ahoppen. I have only been playing around with it, but nothing serious yet. |
|
@swift-ci please test linux |
|
Pinging @ahoppen 😊 |
|
Thanks for the ping, I missed your other comments.
Unfortunately, I don’t know if it’s used at all, but I agree that I think the syntax builder has matured enough that we could start using it for real and refine it based on real world usage. What do you think about the following
What do you think? |
|
That sounds like a good idea! |
No description provided.