|
7 | 7 | // |
8 | 8 | // Permission is hereby granted, free of charge, to any person |
9 | 9 | // obtaining a copy of this software and associated documentation |
10 | | -// files (the “Software”), to deal in the Software without |
| 10 | +// files (the "Software"), to deal in the Software without |
11 | 11 | // restriction, including without limitation the rights to use, |
12 | 12 | // copy, modify, merge, publish, distribute, sublicense, and/or |
13 | 13 | // sell copies of the Software, and to permit persons to whom the |
|
17 | 17 | // The above copyright notice and this permission notice shall be |
18 | 18 | // included in all copies or substantial portions of the Software. |
19 | 19 | // |
20 | | -// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, |
| 20 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
21 | 21 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
22 | 22 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
23 | 23 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
@@ -125,6 +125,14 @@ public struct Closure: CodeBlock { |
125 | 125 | ) |
126 | 126 | } |
127 | 127 |
|
| 128 | + // Prepare return clause safely |
| 129 | + let returnClause: ReturnClauseSyntax? = returnType.map { |
| 130 | + ReturnClauseSyntax( |
| 131 | + arrow: .arrowToken(trailingTrivia: .space), |
| 132 | + type: $0.typeSyntax |
| 133 | + ) |
| 134 | + } |
| 135 | + |
128 | 136 | let signature: ClosureSignatureSyntax? = |
129 | 137 | (parameters.isEmpty && returnType == nil && capture.isEmpty && attributes.isEmpty) |
130 | 138 | ? nil |
@@ -171,12 +179,7 @@ public struct Closure: CodeBlock { |
171 | 179 | ) |
172 | 180 | ), |
173 | 181 | effectSpecifiers: nil, |
174 | | - returnClause: returnType == nil |
175 | | - ? nil |
176 | | - : ReturnClauseSyntax( |
177 | | - arrow: .arrowToken(trailingTrivia: .space), |
178 | | - type: returnType!.typeSyntax |
179 | | - ), |
| 182 | + returnClause: returnClause, |
180 | 183 | inKeyword: .keyword(.in, leadingTrivia: .space, trailingTrivia: .space) |
181 | 184 | ) |
182 | 185 |
|
|
0 commit comments