Skip to content

Commit 8b53f92

Browse files
authored
Merge pull request #2729 from rintaro/static-stored-constant
Turn some static variables into static stored constants
2 parents 62a352d + fad2743 commit 8b53f92

File tree

11 files changed

+2096
-2563
lines changed

11 files changed

+2096
-2563
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,14 @@ func syntaxNode(nodesStartingWith: [Character]) -> SourceFileSyntax {
199199
}
200200
}
201201

202-
try! VariableDeclSyntax("public static var structure: SyntaxNodeStructure") {
203-
let layout = ArrayExprSyntax {
204-
for child in node.children {
205-
ArrayElementSyntax(
206-
expression: ExprSyntax(#"\Self.\#(child.varOrCaseName)"#)
207-
)
208-
}
202+
let layout = ArrayExprSyntax {
203+
for child in node.children {
204+
ArrayElementSyntax(
205+
expression: ExprSyntax(#"\Self.\#(child.varOrCaseName)"#)
206+
)
209207
}
210-
211-
StmtSyntax("return .layout(\(layout))")
212208
}
209+
"public static let structure: SyntaxNodeStructure = .layout(\(layout))"
213210
}
214211
}
215212
}

Sources/SwiftOperators/OperatorTable+Defaults.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extension OperatorTable {
6464
/// without requiring access to the standard library source code. However,
6565
/// because it does not incorporate user-defined operators, it will only
6666
/// ever be useful for a quick approximation.
67-
public static var standardOperators: OperatorTable {
67+
public static let standardOperators: OperatorTable = {
6868
let precedenceGroups: [PrecedenceGroup] = [
6969
PrecedenceGroup(
7070
name: "AssignmentPrecedence",
@@ -437,5 +437,5 @@ extension OperatorTable {
437437
precedenceGroups: precedenceGroups,
438438
operators: operators
439439
)
440-
}
440+
}()
441441
}

0 commit comments

Comments
 (0)