Skip to content

Commit d2011cb

Browse files
committed
Fix an infinte recursion in syntax node casting
1 parent e8e60fb commit d2011cb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
184184
// We know this cast is going to succeed. Go through init(_: SyntaxData)
185185
// to do a sanity check and verify the kind matches in debug builds and get
186186
// maximum performance in release builds.
187-
self = syntax.cast(Self.self)
187+
self = Syntax(syntax).cast(Self.self)
188188
}
189189
"""
190190
)
@@ -205,7 +205,7 @@ let syntaxBaseNodesFile = SourceFileSyntax(leadingTrivia: copyrightHeader) {
205205
// We know this cast is going to succeed. Go through init(_: SyntaxData)
206206
// to do a sanity check and verify the kind matches in debug builds and get
207207
// maximum performance in release builds.
208-
self = syntax.cast(Self.self)
208+
self = Syntax(syntax).cast(Self.self)
209209
}
210210
"""
211211
)

Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public struct DeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
162162
// We know this cast is going to succeed. Go through init(_: SyntaxData)
163163
// to do a sanity check and verify the kind matches in debug builds and get
164164
// maximum performance in release builds.
165-
self = syntax.cast(Self.self)
165+
self = Syntax(syntax).cast(Self.self)
166166
}
167167

168168
/// Create a ``DeclSyntax`` node from a specialized optional syntax node.
@@ -177,7 +177,7 @@ public struct DeclSyntax: DeclSyntaxProtocol, SyntaxHashable {
177177
// We know this cast is going to succeed. Go through init(_: SyntaxData)
178178
// to do a sanity check and verify the kind matches in debug builds and get
179179
// maximum performance in release builds.
180-
self = syntax.cast(Self.self)
180+
self = Syntax(syntax).cast(Self.self)
181181
}
182182

183183
/// Create a ``DeclSyntax`` node from a specialized optional syntax node.
@@ -436,7 +436,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
436436
// We know this cast is going to succeed. Go through init(_: SyntaxData)
437437
// to do a sanity check and verify the kind matches in debug builds and get
438438
// maximum performance in release builds.
439-
self = syntax.cast(Self.self)
439+
self = Syntax(syntax).cast(Self.self)
440440
}
441441

442442
/// Create a ``ExprSyntax`` node from a specialized optional syntax node.
@@ -451,7 +451,7 @@ public struct ExprSyntax: ExprSyntaxProtocol, SyntaxHashable {
451451
// We know this cast is going to succeed. Go through init(_: SyntaxData)
452452
// to do a sanity check and verify the kind matches in debug builds and get
453453
// maximum performance in release builds.
454-
self = syntax.cast(Self.self)
454+
self = Syntax(syntax).cast(Self.self)
455455
}
456456

457457
/// Create a ``ExprSyntax`` node from a specialized optional syntax node.
@@ -738,7 +738,7 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
738738
// We know this cast is going to succeed. Go through init(_: SyntaxData)
739739
// to do a sanity check and verify the kind matches in debug builds and get
740740
// maximum performance in release builds.
741-
self = syntax.cast(Self.self)
741+
self = Syntax(syntax).cast(Self.self)
742742
}
743743

744744
/// Create a ``PatternSyntax`` node from a specialized optional syntax node.
@@ -753,7 +753,7 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
753753
// We know this cast is going to succeed. Go through init(_: SyntaxData)
754754
// to do a sanity check and verify the kind matches in debug builds and get
755755
// maximum performance in release builds.
756-
self = syntax.cast(Self.self)
756+
self = Syntax(syntax).cast(Self.self)
757757
}
758758

759759
/// Create a ``PatternSyntax`` node from a specialized optional syntax node.
@@ -995,7 +995,7 @@ public struct StmtSyntax: StmtSyntaxProtocol, SyntaxHashable {
995995
// We know this cast is going to succeed. Go through init(_: SyntaxData)
996996
// to do a sanity check and verify the kind matches in debug builds and get
997997
// maximum performance in release builds.
998-
self = syntax.cast(Self.self)
998+
self = Syntax(syntax).cast(Self.self)
999999
}
10001000

10011001
/// Create a ``StmtSyntax`` node from a specialized optional syntax node.
@@ -1010,7 +1010,7 @@ public struct StmtSyntax: StmtSyntaxProtocol, SyntaxHashable {
10101010
// We know this cast is going to succeed. Go through init(_: SyntaxData)
10111011
// to do a sanity check and verify the kind matches in debug builds and get
10121012
// maximum performance in release builds.
1013-
self = syntax.cast(Self.self)
1013+
self = Syntax(syntax).cast(Self.self)
10141014
}
10151015

10161016
/// Create a ``StmtSyntax`` node from a specialized optional syntax node.
@@ -1262,7 +1262,7 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
12621262
// We know this cast is going to succeed. Go through init(_: SyntaxData)
12631263
// to do a sanity check and verify the kind matches in debug builds and get
12641264
// maximum performance in release builds.
1265-
self = syntax.cast(Self.self)
1265+
self = Syntax(syntax).cast(Self.self)
12661266
}
12671267

12681268
/// Create a ``TypeSyntax`` node from a specialized optional syntax node.
@@ -1277,7 +1277,7 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
12771277
// We know this cast is going to succeed. Go through init(_: SyntaxData)
12781278
// to do a sanity check and verify the kind matches in debug builds and get
12791279
// maximum performance in release builds.
1280-
self = syntax.cast(Self.self)
1280+
self = Syntax(syntax).cast(Self.self)
12811281
}
12821282

12831283
/// Create a ``TypeSyntax`` node from a specialized optional syntax node.

0 commit comments

Comments
 (0)