Skip to content

Commit 1751c0b

Browse files
Applied review comments
1 parent 50f0688 commit 1751c0b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Sources/SwiftParser/Declarations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ extension Parser {
11451145
var unexpectedAfterAsync: [RawSyntax?] = []
11461146
/// Only allow recovery to the arrow with exprKeyword precedence so we only
11471147
/// skip over misplaced identifiers and don't e.g. recover to an arrow in a 'where' clause.
1148-
if self.at(.arrow) || self.canRecoverTo(TokenSpec(.arrow, recoveryPrecedence: .exprKeyword)) != nil {
1148+
if self.canRecoverTo(TokenSpec(.arrow, recoveryPrecedence: .exprKeyword)) != nil {
11491149
let output = self.parseFunctionReturnClause(effectSpecifiers: &effectSpecifiers, allowNamedOpaqueResultType: true)
11501150
unexpectedAfterAsync.append(RawSyntax(output))
11511151
}

Sources/SwiftParser/Specifiers.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ extension RawDeinitEffectSpecifiersSyntax: RawMisplacedEffectSpecifiersTrait {
527527
throwsSpecifier: RawTokenSyntax?,
528528
arena: __shared SwiftSyntax.SyntaxArena
529529
) {
530-
// Inserted missing throws is discarded
530+
// `throwsSpecifier` should never be present because `parseMisplacedEffectSpecifiers()` only creates missing tokens
531+
// and `CorrectThrowsTokenKinds` is an empty `TokenSpecSet`.
532+
//
533+
// We don't want to insert missing `throws` for deinit case,
534+
// so if `parseMisplacedEffectSpecifiers()` creates one it will be discarded here.
531535
precondition(throwsSpecifier?.isMissing ?? true)
532536
self.init(
533537
nil,
@@ -540,7 +544,11 @@ extension RawDeinitEffectSpecifiersSyntax: RawMisplacedEffectSpecifiersTrait {
540544
func withMisplaced(async misplacedAsyncKeyword: RawTokenSyntax?, throws misplacedThrowsKeyword: RawTokenSyntax?, arena: SyntaxArena)
541545
-> RawDeinitEffectSpecifiersSyntax
542546
{
543-
// Inserted missing throws is discarded
547+
// `throwsSpecifier` should never be present because `parseMisplacedEffectSpecifiers()` only creates missing tokens
548+
// and `CorrectThrowsTokenKinds` is an empty `TokenSpecSet`.
549+
//
550+
// We don't want to insert missing `throws` for deinit case,
551+
// so if `parseMisplacedEffectSpecifiers()` creates one it will be discarded here.
544552
precondition(throwsSpecifier?.isMissing ?? true)
545553
return Self.init(
546554
self.unexpectedBeforeAsyncSpecifier,

0 commit comments

Comments
 (0)