@@ -21,14 +21,14 @@ import SwiftSyntax
21
21
/// `default`; in that case, the fallthrough `case` is deleted.
22
22
public final class NoCasesWithOnlyFallthrough : SyntaxFormatRule {
23
23
24
- public override func visit( _ node: SwitchCaseListSyntax ) -> Syntax {
24
+ public override func visit( _ node: SwitchCaseListSyntax ) -> SwitchCaseListSyntax {
25
25
var newChildren : [ Syntax ] = [ ]
26
26
var fallthroughOnlyCases : [ SwitchCaseSyntax ] = [ ]
27
27
28
28
/// Flushes any un-collapsed violations to the new cases list.
29
29
func flushViolations( ) {
30
30
fallthroughOnlyCases. forEach {
31
- newChildren. append ( super. visit ( $0) )
31
+ newChildren. append ( Syntax ( super. visit ( $0) ) )
32
32
}
33
33
fallthroughOnlyCases. removeAll ( )
34
34
}
@@ -50,14 +50,14 @@ public final class NoCasesWithOnlyFallthrough: SyntaxFormatRule {
50
50
guard !fallthroughOnlyCases. isEmpty else {
51
51
// If there are no violations recorded, just append the case. There's nothing we can try
52
52
// to merge into it.
53
- newChildren. append ( visit ( switchCase) )
53
+ newChildren. append ( Syntax ( visit ( switchCase) ) )
54
54
continue
55
55
}
56
56
57
57
if canMergeWithPreviousCases ( switchCase) {
58
58
// If the current case can be merged with the ones before it, merge them all, leaving no
59
59
// `fallthrough`-only cases behind.
60
- newChildren. append ( visit ( mergedCases ( fallthroughOnlyCases + [ switchCase] ) ) )
60
+ newChildren. append ( Syntax ( visit ( mergedCases ( fallthroughOnlyCases + [ switchCase] ) ) ) )
61
61
} else {
62
62
// If the current case can't be merged with the ones before it, merge the previous ones
63
63
// into a single `fallthrough`-only case and then append the current one. This could
@@ -71,8 +71,8 @@ public final class NoCasesWithOnlyFallthrough: SyntaxFormatRule {
71
71
// the program's behavior.
72
72
// 3. The current case is `@unknown default`, which can't be merged notwithstanding the
73
73
// side-effect issues discussed above.
74
- newChildren. append ( visit ( mergedCases ( fallthroughOnlyCases) ) )
75
- newChildren. append ( visit ( switchCase) )
74
+ newChildren. append ( Syntax ( visit ( mergedCases ( fallthroughOnlyCases) ) ) )
75
+ newChildren. append ( Syntax ( visit ( switchCase) ) )
76
76
}
77
77
78
78
fallthroughOnlyCases. removeAll ( )
@@ -83,7 +83,7 @@ public final class NoCasesWithOnlyFallthrough: SyntaxFormatRule {
83
83
// anything.
84
84
flushViolations ( )
85
85
86
- return Syntax ( SwitchCaseListSyntax ( newChildren) )
86
+ return SwitchCaseListSyntax ( newChildren)
87
87
}
88
88
89
89
/// Returns true if this case can definitely be merged with any that come before it.
0 commit comments