Skip to content

Commit b74a8d4

Browse files
committed
Follow up of #2564
1 parent bc189ce commit b74a8d4

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,11 @@ public let TYPE_NODES: [Node] = [
570570
experimentalFeature: .nonescapableTypes,
571571
nameForDiagnostics: "lifetime specifier",
572572
documentation: "A specifier that specifies function parameter on whose lifetime a type depends",
573-
traits: [
574-
"Parenthesized"
575-
],
576573
children: [
577574
Child(
578575
name: "dependsOnKeyword",
579576
kind: .token(choices: [.keyword(.dependsOn)]),
580-
documentation: "The specifier token that's attached to the type."
577+
documentation: "lifetime dependence specifier on the return type"
581578
),
582579
Child(
583580
name: "leftParen",
@@ -586,6 +583,7 @@ public let TYPE_NODES: [Node] = [
586583
Child(
587584
name: "scopedKeyword",
588585
kind: .token(choices: [.keyword(.scoped)]),
586+
documentation: "scoped lifetime dependence specifier",
589587
isOptional: true
590588
),
591589
Child(

Sources/SwiftParser/Types.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ extension Parser.Lookahead {
901901

902902
extension Parser {
903903
private mutating func parseLifetimeTypeSpecifier() -> RawTypeSpecifierListSyntax.Element {
904-
let specifier = self.eat(TokenSpec(.dependsOn))
904+
let (unexpectedBeforeDependsOnKeyword, dependsOnKeyword) = self.expect(.keyword(.dependsOn))
905905

906906
guard let leftParen = self.consume(if: .leftParen) else {
907907
// If there is no left paren, add an entirely missing detail. Otherwise, we start to consume the following type
@@ -916,7 +916,8 @@ extension Parser {
916916
arena: self.arena
917917
)
918918
let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax(
919-
dependsOnKeyword: specifier,
919+
unexpectedBeforeDependsOnKeyword,
920+
dependsOnKeyword: dependsOnKeyword,
920921
leftParen: missingToken(.leftParen),
921922
scopedKeyword: nil,
922923
arguments: arguments,
@@ -952,7 +953,8 @@ extension Parser {
952953
arena: self.arena
953954
)
954955
let lifetimeSpecifier = RawLifetimeTypeSpecifierSyntax(
955-
dependsOnKeyword: specifier,
956+
unexpectedBeforeDependsOnKeyword,
957+
dependsOnKeyword: dependsOnKeyword,
956958
leftParen: leftParen,
957959
scopedKeyword: scoped,
958960
arguments: argumentsSyntax,
@@ -981,7 +983,7 @@ extension Parser {
981983
SPECIFIER_PARSING: while canHaveParameterSpecifier {
982984
if let (_, specifierHandle) = self.at(anyIn: SimpleTypeSpecifierSyntax.SpecifierOptions.self) {
983985
specifiers.append(parseSimpleTypeSpecifier(specifierHandle: specifierHandle))
984-
} else if self.at(TokenSpec(.dependsOn)) {
986+
} else if self.at(.keyword(.dependsOn)) {
985987
if self.experimentalFeatures.contains(.nonescapableTypes) {
986988
specifiers.append(parseLifetimeTypeSpecifier())
987989
} else {

Sources/SwiftSyntax/generated/SyntaxTraits.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,6 @@ extension LabeledSpecializeArgumentSyntax: WithTrailingCommaSyntax {}
779779

780780
extension LifetimeSpecifierArgumentSyntax: WithTrailingCommaSyntax {}
781781

782-
extension LifetimeTypeSpecifierSyntax: ParenthesizedSyntax {}
783-
784782
extension MacroDeclSyntax: NamedDeclSyntax, WithAttributesSyntax, WithGenericParametersSyntax, WithModifiersSyntax {}
785783

786784
extension MacroExpansionDeclSyntax: FreestandingMacroExpansionSyntax, WithAttributesSyntax, WithModifiersSyntax {}

Sources/SwiftSyntax/generated/syntaxNodes/SyntaxNodesJKLMN.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,8 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf
19351935

19361936
/// - Parameters:
19371937
/// - leadingTrivia: Trivia to be prepended to the leading trivia of the node’s first token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
1938-
/// - dependsOnKeyword: The specifier token that's attached to the type.
1938+
/// - dependsOnKeyword: lifetime dependence specifier on the return type
1939+
/// - scopedKeyword: scoped lifetime dependence specifier
19391940
/// - trailingTrivia: Trivia to be appended to the trailing trivia of the node’s last token. If the node is empty, there is no token to attach the trivia to and the parameter is ignored.
19401941
public init(
19411942
leadingTrivia: Trivia? = nil,
@@ -2002,7 +2003,7 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf
20022003
}
20032004
}
20042005

2005-
/// The specifier token that's attached to the type.
2006+
/// lifetime dependence specifier on the return type
20062007
///
20072008
/// ### Tokens
20082009
///
@@ -2046,6 +2047,8 @@ public struct LifetimeTypeSpecifierSyntax: SyntaxProtocol, SyntaxHashable, _Leaf
20462047
}
20472048
}
20482049

2050+
/// scoped lifetime dependence specifier
2051+
///
20492052
/// ### Tokens
20502053
///
20512054
/// For syntax trees generated by the parser, this is guaranteed to be `scoped`.

0 commit comments

Comments
 (0)