Skip to content

Commit d1495af

Browse files
authored
Merge pull request #956 from hamishknight/review-comments
2 parents a09125e + 2904a2c commit d1495af

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,11 +1121,7 @@ extension Parser {
11211121
}
11221122

11231123
// Detect an attempt to use a type parameter pack.
1124-
var unexpectedAfterName: RawUnexpectedNodesSyntax?
1125-
if let ellipsis = tryConsumeEllipsisPrefix() {
1126-
unexpectedAfterName = RawUnexpectedNodesSyntax(
1127-
elements: [RawSyntax(ellipsis)], arena: self.arena)
1128-
}
1124+
let ellipsis = tryConsumeEllipsisPrefix()
11291125

11301126
// Parse optional inheritance clause.
11311127
let inheritance: RawTypeInheritanceClauseSyntax?
@@ -1162,7 +1158,7 @@ extension Parser {
11621158
associatedtypeKeyword: assocKeyword,
11631159
unexpectedBeforeName,
11641160
identifier: name,
1165-
unexpectedAfterName,
1161+
RawUnexpectedNodesSyntax([ellipsis], arena: self.arena),
11661162
inheritanceClause: inheritance,
11671163
initializer: defaultType,
11681164
genericWhereClause: whereClause,

Sources/SwiftParser/Diagnostics/ParseDiagnosticsGenerator.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
145145
addDiagnostic(incorrectContainer, message(misplacedTokens), fixIts: fixIts, handledNodes: [incorrectContainer.id] + correctAndMissingTokens.map(\.id))
146146
}
147147

148-
/// Utility function to remove a misplaced token with a custom error message.
148+
/// If `unexpected` only contains a single token that satisfies `predicate`,
149+
/// emits a diagnostic with `message` that removes this token.
149150
public func removeToken(
150151
_ unexpected: UnexpectedNodesSyntax?,
151152
where predicate: (TokenSyntax) -> Bool,

0 commit comments

Comments
 (0)