Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit 2de809d

Browse files
hbhallevato
authored andcommitted
Fix issues introduced by SwiftSyntax changes.
A recent change to SwiftSyntax broke our build: swiftlang#16155 PiperOrigin-RevId: 194541217
1 parent 80852e7 commit 2de809d

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Sources/Rules/UseEnumForNamespacing.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,22 @@ public final class UseEnumForNamespacing: SyntaxFormatRule {
6969
/// Determines if the set of declarations is consistent with a class or struct being used
7070
/// solely as a namespace for static functions. If there is a non-static private initializer
7171
/// with no arguments, that does not count against possibly being a namespace.
72-
func declsIfUsedAsNamespace(_ decls: DeclListSyntax) -> DeclListSyntax? {
73-
var declList = [DeclSyntax]()
74-
for decl in decls {
75-
switch decl {
72+
func declsIfUsedAsNamespace(_ members: MemberDeclListSyntax) -> MemberDeclListSyntax? {
73+
var declList = [MemberDeclListItemSyntax]()
74+
for member in members {
75+
switch member.decl {
7676
case let decl as FunctionDeclSyntax:
7777
guard let modifiers = decl.modifiers,
7878
modifiers.has(modifier: "static") else {
7979
return nil
8080
}
81-
declList.append(decl)
81+
declList.append(member)
8282
case let decl as VariableDeclSyntax:
8383
guard let modifiers = decl.modifiers,
8484
modifiers.has(modifier: "static") else {
8585
return nil
8686
}
87-
declList.append(decl)
87+
declList.append(member)
8888
case let decl as InitializerDeclSyntax:
8989
guard let modifiers = decl.modifiers,
9090
modifiers.has(modifier: "private"),
@@ -93,10 +93,10 @@ public final class UseEnumForNamespacing: SyntaxFormatRule {
9393
}
9494
// Do not append private initializer
9595
default:
96-
declList.append(decl)
96+
declList.append(member)
9797
}
9898
}
99-
return SyntaxFactory.makeDeclList(declList)
99+
return SyntaxFactory.makeMemberDeclList(declList)
100100
}
101101
}
102102

Sources/generate-pipeline/main.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ for baseName in fm.enumerator(atPath: rulesDir.path)! {
6060
continue
6161
}
6262
for member in classDecl.members.members {
63-
guard let function = member as? FunctionDeclSyntax, let modifiers = function.modifiers else {
63+
guard let function = member.decl as? FunctionDeclSyntax,
64+
let modifiers = function.modifiers else {
6465
continue
6566
}
6667
guard modifiers.contains(where: { $0.name.text == "override" }) else { continue }

0 commit comments

Comments
 (0)