@@ -32,7 +32,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
32
32
return decl
33
33
}
34
34
35
- funcDecl. body? . statements = unwrapReturnStmt ( returnStmt)
35
+ funcDecl. body? . statements = rewrapReturnedExpression ( returnStmt)
36
36
diagnose ( . omitReturnStatement, on: returnStmt, severity: . refactoring)
37
37
return DeclSyntax ( funcDecl)
38
38
}
@@ -73,7 +73,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
73
73
return expr
74
74
}
75
75
76
- closureExpr. statements = unwrapReturnStmt ( returnStmt)
76
+ closureExpr. statements = rewrapReturnedExpression ( returnStmt)
77
77
diagnose ( . omitReturnStatement, on: returnStmt, severity: . refactoring)
78
78
return ExprSyntax ( closureExpr)
79
79
}
@@ -100,7 +100,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
100
100
return nil
101
101
}
102
102
103
- getter. body? . statements = unwrapReturnStmt ( returnStmt)
103
+ getter. body? . statements = rewrapReturnedExpression ( returnStmt)
104
104
105
105
diagnose ( . omitReturnStatement, on: returnStmt, severity: . refactoring)
106
106
@@ -116,7 +116,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
116
116
diagnose ( . omitReturnStatement, on: returnStmt, severity: . refactoring)
117
117
118
118
var newBlock = accessorBlock
119
- newBlock. accessors = . getter( unwrapReturnStmt ( returnStmt) )
119
+ newBlock. accessors = . getter( rewrapReturnedExpression ( returnStmt) )
120
120
return newBlock
121
121
}
122
122
}
@@ -131,7 +131,7 @@ public final class OmitExplicitReturns: SyntaxFormatRule {
131
131
return !returnStmt. children ( viewMode: . all) . isEmpty && returnStmt. expression != nil ? returnStmt : nil
132
132
}
133
133
134
- private func unwrapReturnStmt ( _ returnStmt: ReturnStmtSyntax ) -> CodeBlockItemListSyntax {
134
+ private func rewrapReturnedExpression ( _ returnStmt: ReturnStmtSyntax ) -> CodeBlockItemListSyntax {
135
135
CodeBlockItemListSyntax ( [
136
136
CodeBlockItemSyntax (
137
137
leadingTrivia: returnStmt. leadingTrivia,
0 commit comments