-
Notifications
You must be signed in to change notification settings - Fork 441
Parse an ellipsis T...
for type parameter packs
#948
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
In a generic parameter list, parse an ellipsis to produce a type parameter pack. This replaces the previous `@_typeSequence` attribute.
This is no longer needed now that we have the ellipsis spelling.
@swift-ci please test |
// Detect an attempt to use a type parameter pack. | ||
var unexpectedAfterName: RawUnexpectedNodesSyntax? | ||
if let ellipsis = tryConsumeEllipsisPrefix() { | ||
unexpectedAfterName = RawUnexpectedNodesSyntax( | ||
elements: [RawSyntax(ellipsis)], arena: self.arena) | ||
} | ||
|
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.
There is a convenience initializer on RawUnexpectedNodesSyntax
that fails if it is passed only nil elements, so this can be simplified to
let ellipsis = tryConsumeEllipsisPrefix()
and then below where you are currently passing unexpectedAfterName
to the RawAssociatedtypeDeclSyntax
initializer:
RawUnexpectedNodesSyntax(ellipsis, arena: self.arena)
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.
Neat!
@@ -145,6 +145,29 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor { | |||
addDiagnostic(incorrectContainer, message(misplacedTokens), fixIts: fixIts, handledNodes: [incorrectContainer.id] + correctAndMissingTokens.map(\.id)) | |||
} | |||
|
|||
/// Utility function to remove a misplaced token with a custom error message. |
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.
If you agree, I think the following comment is a little more descriptive.
/// If `unexpected` only contains a single token that satisfies `predicate` emit a diagnostic with `message` that removes this token.
In a generic parameter list, parse an ellipsis to produce a type parameter pack. This replaces the previous
@_typeSequence
attribute.