Skip to content

Commit

Permalink
Remove unreliable assert
Browse files Browse the repository at this point in the history
  • Loading branch information
nicklockwood committed Aug 19, 2023
1 parent d9c558d commit 98d99b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion Sources/FormattingHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2511,7 +2511,6 @@ extension Formatter {
usingDynamicLookup: usingDynamicLookup,
classOrStatic: classOrStatic)
classOrStatic = false
assert(self.token(at: index) != .endOfScope("}"))
continue
case .keyword("static"):
if !isTypeRoot {
Expand Down
7 changes: 7 additions & 0 deletions Tests/RulesTests+Redundancy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6508,6 +6508,13 @@ class RedundancyTests: RulesTests {
testFormatting(for: input, rule: FormatRules.redundantStaticSelf)
}

func testPreserveStaticSelfInSingleLineClassInit() {
let input = """
class A { static let defaultName = "A"; let name: String; init() { name = Self.defaultName }}
"""
testFormatting(for: input, rule: FormatRules.redundantStaticSelf)
}

// MARK: - semicolons

func testSemicolonRemovedAtEndOfLine() {
Expand Down

0 comments on commit 98d99b9

Please sign in to comment.