-
Notifications
You must be signed in to change notification settings - Fork 440
Generate extensions for protocolsMap.py #339
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
Generate extensions for protocolsMap.py #339
Conversation
% for protocol, conformances in SYNTAX_BUILDABLE_EXPRESSIBLE_AS_CONFORMANCES.items(): | ||
% if 'ExpressibleAsConditionElementList' in conformances: | ||
extension ${protocol} { | ||
public func createConditionElementList() -> ConditionElementList { | ||
ConditionElementList([self]) | ||
} | ||
} | ||
|
||
% end | ||
% end |
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.
This one properly slipped through when added #334
% for conformance in conformances: | ||
% node = NODE_MAP.get(conformance) | ||
% if node and node.children: | ||
% param = filter(lambda x : x.type_name != "TokenSyntax", node.children)[0].swift_name |
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 don’t think this is correct. We want to the first child that doesn’t have a default value. Currently optional children also have a default value of nil
and TokenSyntax
children might not have a default value if they don’t have a default text (see https://github.com/apple/swift/blob/17f1cf92973d2c1b3d5fe6b70f4a33771a303e3a/utils/gyb_syntax_support/kinds.py#L58-L64)
I think a better implementation would be
non_defaulted_params = filter(lambda child : syntax_buildable_default_init_value(child, SYNTAX_TOKEN_MAP.get(child.syntax_kind)) == None, node.children)
assert len(non_defaulted_params) == 1, "ExpressibleAs conformances expects the conforming type to have an initializer with a single non-optional child"
param = non_defaulted_params[0].swift_name
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.
Ah, I didn't see that.
Added. Tough changes the == None
to == ""
as we return an empty string.
2355440
to
8d74eda
Compare
@swift-ci Please test |
@swift-ci Please test |
Generate extensions for protocolsMap.py.