@@ -137,6 +137,7 @@ limitXY(someInt, toGamut: intArray) {} // expected-error{{extra trailing closur
137
137
// <rdar://problem/23036383> QoI: Invalid trailing closures in stmt-conditions produce lowsy diagnostics
138
138
func retBool( x: ( ) -> Int ) -> Bool { }
139
139
func maybeInt( _: ( ) -> Int ) -> Int ? { }
140
+ func twoClosureArgs( _: ( ) -> Void , _: ( ) -> Void ) -> Bool { }
140
141
class Foo23036383 {
141
142
init ( ) { }
142
143
func map( _: ( Int ) -> Int ) -> Int ? { }
@@ -201,7 +202,82 @@ func r23036383(foo: Foo23036383?, obj: Foo23036383) {
201
202
202
203
if let _ = maybeInt { 1 } , retBool { 1 } { }
203
204
// 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=)}}
205
+ // expected-error@-2 {{trailing closure requires parentheses for disambiguation in this context}} {{37-38=(x: }} {{43-43=)}}
206
+
207
+ if let _ = foo? . map { $0+ 1 } . map { $0+ 1 } { } // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{33-34=(}} {{40-40=)}}
208
+ // expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
209
+
210
+ if let _ = foo? . map { $0+ 1 } . map ( { $0+ 1 } ) { } // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
211
+
212
+ if let _ = foo? . map { $0+ 1 } . map ( { $0+ 1 } ) . map { $0+ 1 } { } // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{45-45=(}} {{51-51=)}}
213
+ // expected-error@-1 {{trailing closure requires parentheses for disambiguation in this context}} {{22-23=(}} {{29-29=)}}
214
+
215
+ if twoClosureArgs ( { } ) { } { } // expected-error {{trailing closure requires parentheses for disambiguation in this context}} {{23-25=, }} {{27-27=)}}
216
+
217
+ if let _ = ( foo? . map { $0+ 1 } . map ( { $0+ 1 } ) . map { $0+ 1 } ) { } // OK
218
+
219
+ if let _ = ( foo? . map { $0+ 1 } . map ( { $0+ 1 } ) ) . map ( { $0+ 1 } ) { } // OK
220
+ }
221
+
222
+ func id< T> ( fn: ( ) -> T ) -> T { return fn ( ) }
223
+ func any< T> ( fn: ( ) -> T ) -> Any { return fn ( ) }
224
+
225
+ func testSR8736( ) {
226
+ if !id { true } { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
227
+
228
+ if id { true } == true { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
229
+
230
+ if true == id { true } { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
231
+
232
+ if id { true } ? true : false { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
233
+
234
+ if true ? id { true } : false { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
235
+
236
+ if true ? true : id { false } { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
237
+
238
+ if id { [ false , true ] } [ 0 ] { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
239
+
240
+ if id { { true } } ( ) { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
241
+
242
+ if any { true } as! Bool { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
243
+
244
+ if let _ = any { " test " } as? Int { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
245
+
246
+ if any { " test " } is Int { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
247
+
248
+ if let _ = id { [ ] as [ Int ] ? } ? . first { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
249
+
250
+ if id { true as Bool ? } ! { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
251
+
252
+ if case id { 1 } = 1 { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
253
+
254
+ if case 1 = id { 1 } { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
255
+
256
+ if case 1 = id { 1 } /*comment*/ { return } // expected-error {{trailing closure requires parentheses for disambiguation in this context}}
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}}
272
+
273
+ if true { }
274
+ ( ) // OK
275
+
276
+ if true
277
+ {
278
+
279
+ }
280
+ ( ) // OK
205
281
}
206
282
207
283
func overloadOnLabel( a: ( ) -> Void ) { }
0 commit comments