-
Notifications
You must be signed in to change notification settings - Fork 440
[Variadic Generics] Add a new type syntax node and parsing support for explicit pack references. #1134
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
[Variadic Generics] Add a new type syntax node and parsing support for explicit pack references. #1134
Conversation
@swift-ci please test |
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.
Could you add a couple of test cases? Interesting test cases that come to my mind are
- the example in your PR description
each MyType
as a parameter / return type (I assume that this should be invalid but we can/should defer diagnostic generation for this case to ASTGen since we cannot forbideach MyType
in the current SwiftSyntax tree)
@@ -123,6 +123,14 @@ | |||
Child('Ellipsis', kind='EllipsisToken') | |||
]), | |||
|
|||
# pack-reference-type -> 'each' type | |||
Node('PackReferenceType', name_for_diagnostics='pack reference', kind='Type', |
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 node is identical to the ConstrainedSugarType
. What do you think about using the same node type for it instead of introducing a new node? I'm open to naming suggestions.
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.
Hmm. You're right that the syntactic structure is the same (though it's parsed slightly differently), but conceptually a pack element type is very different from a constrained sugar type. Do you think that most tooling operating on these type syntax nodes would want to treat pack elements the same as constraint types? The only reason why I added a new syntax node is because I added a new TypeRepr
on the Swift side to make type resolution easier, since the resolution logic is completely different.
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 was an open question, maybe I should have phrased that more clearly. It was motivated because I’m merging the nodes for #available
and #unavailable
in #1125 and that simplified quite a few things. If you think it’s better to have different nodes for some
/any
and each
, I’m totally fine with it.
I have test cases in my PR to the Swift repo here: https://github.com/apple/swift/pull/62509/files#diff-b4b3fbedbd5cb01a2a671c3e6e039e0bdc87f29ae3744e6aa6a713b32bb9ad04. These should exercise this code through parser validation. Do I need to add test cases here in addition to those? |
91035df
to
227fe88
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
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.
Thanks for adding the test cases. LGTM 👍
…rd applied to type parameter pack references.
227fe88
to
ded777e
Compare
@swift-ci please test |
PackReferenceType
, for pack references spelled with a contextualeach
keyword.PackReferenceTypeSyntax
when the contextualeach
keyword is applied to a type.