Skip to content

Commit e5f5dd9

Browse files
authored
Merge pull request swiftlang#180 from dabelknap/enumnamespace-modifiers
UseEnumForNamespacing: Remove the 'final' keyword when transforming from a class
2 parents e751900 + 9f1b62d commit e5f5dd9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Sources/SwiftFormatRules/UseEnumForNamespacing.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public final class UseEnumForNamespacing: SyntaxFormatRule {
6666
name: TokenSyntax,
6767
members: MemberDeclBlockSyntax
6868
) -> EnumDeclSyntax {
69+
let newModifiers = modifiers?.remove(name: "final")
6970
return EnumDeclSyntax {
70-
if let mods = modifiers {
71+
if let mods = newModifiers {
7172
for mod in mods { $0.addModifier(mod) }
7273
}
7374
$0.useEnumKeyword(declarationKeyword.withKind(.enumKeyword))

Tests/SwiftFormatRulesTests/UseEnumForNamespacingTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class UseEnumForNamespacingTests: DiagnosingTestCase {
2121
class C {
2222
static func foo() {}
2323
}
24+
public final class D {
25+
static func bar()
26+
}
2427
""",
2528
expected: """
2629
enum A {
@@ -34,6 +37,9 @@ public class UseEnumForNamespacingTests: DiagnosingTestCase {
3437
enum C {
3538
static func foo() {}
3639
}
40+
public enum D {
41+
static func bar()
42+
}
3743
""")
3844
}
3945

0 commit comments

Comments
 (0)