-
Notifications
You must be signed in to change notification settings - Fork 440
Add default conformance to syntax collection #334
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
Add default conformance to syntax collection #334
Conversation
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.
LGTM. Will probably need some adjustment based on which changes will be made to swiftlang/swift#40120.
05810f0
to
fe3d42b
Compare
|
||
% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_BY_CONFORMANCES.items(): | ||
% if 'ConditionElement' in conformances: | ||
extension ExpressibleBy${protocol} { |
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.
Not part of this PR, but couldn’t we also generate these extension
implementations now that syntax collection conformances live somewhere else?
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 would be nice!
But the thing is, that the init method different for each type.
We can enrich the protocols.py
file with the needed information.
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.
Why is that? Am I missing something obvious? Shouldn’t the following work?
extension ExpressibleBy${protocol} {
public func create${expressible_as_protocol}() -> ${expressible_as_protocol} {
${expressible_as_protocol}(${retrieve only non-optional child name here}: self)
}
}
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.
Sorry bad explanation 😅
extension ExpressibleByDeclBuildable {
public func createCodeBlockItem() -> CodeBlockItem {
CodeBlockItem(item: self)
}
}
extension ExpressibleByDeclBuildable {
public func createMemberDeclListItem() -> MemberDeclListItem {
MemberDeclListItem(decl: self)
}
}
Yes. The ${retrieve only non-optional child name here}
do we need to find somehow.
Not sure how to do, but I will look into it, and then we can take it from there.
It is possible, somehow 😬
fe3d42b
to
72e2627
Compare
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.
Looking good. Could you rebase because I just reverted my change of ExpressibleAs
-> ExpressibleBy
because I had a brain fart yesterday. The protocols actually describe that these types are expressible as other types and not by other types. Also make sure to rename all of your by
s by as
s.
72e2627
to
a52dca1
Compare
I saw that! I have rebased 🚀 |
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
swiftlang/swift#40120
Added default conformance to syntax collection as discussed in #331