You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if retBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{13-13=(x: }} {{18-18=)}}
157
+
if retBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{13-13=(x: }} {{18-18=)}}
157
158
}
158
-
if retBool {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{13-14=(x: }} {{19-19=)}}
159
+
if retBool {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{13-14=(x: }} {{19-19=)}}
159
160
}
160
-
ifretBool(){1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{14-16=x: }} {{21-21=)}}
161
-
}elseifretBool(){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{21-24=x: }} {{29-29=)}}
161
+
ifretBool(){1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{14-16=x: }} {{21-21=)}}
162
+
}elseifretBool(){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{21-24=x: }} {{29-29=)}}
162
163
}
163
164
164
-
iflet _ = maybeInt {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
165
+
iflet _ = maybeInt {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
165
166
}
166
-
iflet _ =maybeInt{1},true{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
167
+
iflet _ =maybeInt{1},true{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
167
168
}
168
169
169
-
iflet _ = foo?.map {$0+1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
170
+
iflet _ = foo?.map {$0+1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
170
171
}
171
-
iflet _ = foo?.map(){$0+1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{23-25=}} {{31-31=)}}
172
+
iflet _ = foo?.map(){$0+1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{23-25=}} {{31-31=)}}
172
173
}
173
-
iflet _ = foo, retBool {1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{26-27=(x: }} {{32-32=)}}
174
+
iflet _ = foo, retBool {1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{26-27=(x: }} {{32-32=)}}
174
175
}
175
176
176
-
if obj.meth1(x:1){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{20-22=, }} {{27-27=)}}
177
+
if obj.meth1(x:1){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{20-22=, }} {{27-27=)}}
177
178
}
178
-
if obj.meth2(1){0}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{17-19=, y: }} {{24-24=)}}
179
+
if obj.meth2(1){0}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{17-19=, y: }} {{24-24=)}}
179
180
}
180
181
181
-
for_inobj.filter{$0 >4}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(by: }} {{31-31=)}}
182
+
for_inobj.filter{$0 >4}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(by: }} {{31-31=)}}
182
183
}
183
-
for_inobj.filter{$0 >4}wheretrue{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(by: }} {{31-31=)}}
184
+
for_inobj.filter{$0 >4}wheretrue{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(by: }} {{31-31=)}}
184
185
}
185
-
for_in[1,2]whereretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{31-32=(x: }} {{37-37=)}}
186
+
for_in[1,2]whereretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{31-32=(x: }} {{37-37=)}}
186
187
}
187
188
188
-
whileretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{16-17=(x: }} {{22-22=)}}
189
+
whileretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{16-17=(x: }} {{22-22=)}}
189
190
}
190
-
whilelet _ = foo,retBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{29-30=(x: }} {{35-35=)}}
191
+
whilelet _ = foo,retBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{29-30=(x: }} {{35-35=)}}
191
192
}
192
193
193
-
switchretBool{return1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{17-18=(x: }} {{30-30=)}}
194
+
switchretBool{return1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{17-18=(x: }} {{30-30=)}}
194
195
default:break
195
196
}
196
197
197
198
do{
198
199
throwMyErr.A;
199
-
}catchMyErr.A whereretBool{1}{ // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{32-33=(x: }} {{38-38=)}}
200
+
}catchMyErr.A whereretBool{1}{ // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{32-33=(x: }} {{38-38=)}}
200
201
}catch{}
201
202
202
203
iflet _ =maybeInt{1}, retBool {1}{}
203
-
// expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{28-28=)}}
204
-
// expected-error@-2 {{trailing closure requires parentheses for disambiguation in this context}} {{37-38=(x: }} {{43-43=)}}
204
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{28-28=)}}
205
+
// expected-warning@-2 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{37-38=(x: }} {{43-43=)}}
206
+
207
+
iflet _ = foo?.map {$0+1}.map{$0+1}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{33-34=(}} {{40-40=)}}
208
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
209
+
210
+
iflet _ = foo?.map {$0+1}.map({$0+1}){} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
211
+
212
+
iflet _ = foo?.map {$0+1}.map({$0+1}).map{$0+1}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{45-45=(}} {{51-51=)}}
213
+
// expected-warning@-1 {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{22-23=(}} {{29-29=)}}
214
+
215
+
iftwoClosureArgs({}){}{} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}} {{23-25=, }} {{27-27=)}}
216
+
217
+
iflet _ =(foo?.map{$0+1}.map({$0+1}).map{$0+1}){} // OK
218
+
219
+
iflet _ =(foo?.map{$0+1}.map({$0+1})).map({$0+1}){} // OK
220
+
}
221
+
222
+
func id<T>(fn:()->T)->T{returnfn()}
223
+
func any<T>(fn:()->T)->Any{returnfn()}
224
+
225
+
func testSR8736(){
226
+
if !id {true}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
227
+
228
+
if id {true}==true{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
229
+
230
+
iftrue== id {true}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
231
+
232
+
if id {true}?true:false{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
233
+
234
+
iftrue?id{true}:false{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
235
+
236
+
iftrue?true: id {false}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
237
+
238
+
if id {[false,true]}[0]{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
239
+
240
+
if id {{true}}(){return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
241
+
242
+
if any {true}as!Bool{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
243
+
244
+
iflet _ = any {"test"}as?Int{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
245
+
246
+
if any {"test"} is Int{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
247
+
248
+
iflet _ = id {[]as[Int]?}?.first{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
249
+
250
+
if id {trueasBool?}! {return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
251
+
252
+
if case id {1}=1{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
253
+
254
+
if case 1=id{1}{return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
255
+
256
+
if case 1=id{1} /*comment*/ {return} // expected-warning {{trailing closure in this context is confusable with the body of the statement; pass as a parenthesized argument to silence this warning}}
257
+
258
+
if case (id{1})=1{return} // OK
259
+
260
+
if case 1=(id{1}){return} // OK
261
+
262
+
if [id{true}].count ==0{return} // OK
263
+
264
+
if [id{true}:"test"].keys.count ==0{return} // OK
265
+
266
+
if "\(id {true})"=="foo"{return} // OK
267
+
268
+
if(id{true}){return} // OK
269
+
270
+
if(id{true}){}
271
+
[1,2,3].count // expected-warning {{expression of type 'Int' is unused}}
0 commit comments