-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathcomplete_in_closures.swift
433 lines (371 loc) · 20 KB
/
complete_in_closures.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_CLOSURE_PARAM_1 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_CLOSURE_PARAM_2 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_1 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_2 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_3 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_4 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_5 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RESOLVE_PARENT_PARAM_6 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RETURN_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_2 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_3 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_4 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_5 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_6 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_7 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_8 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_9 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DELAYED_10 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS_AND_LOCAL1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_2 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_3 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_4 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_5 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_6 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_7 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_8 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_9 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_10 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_11 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_12 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_13 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_14 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_15 | %FileCheck %s -check-prefix=FOO_OBJECT_DOT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_16 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_17 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_18 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_TRAILING_CLOSURE_19 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INHERITANCE_IN_CLOSURE_0 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLASS_INHERITANCE_IN_CLOSURE_0 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARGUMENT_TYPE_IN_CLOSURE_0 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INHERITANCE_IN_CLOSURE_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLASS_INHERITANCE_IN_CLOSURE_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARGUMENT_TYPE_IN_CLOSURE_1 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=STRUCT_INHERITANCE_IN_CLOSURE_2 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLASS_INHERITANCE_IN_CLOSURE_2 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ARGUMENT_TYPE_IN_CLOSURE_2 | %FileCheck %s -check-prefix=WITH_GLOBAL_DECLS
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLOSURE_PARAM_1 | %FileCheck %s -check-prefix=CLOSURE_PARAM_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=CLOSURE_PARAM_2 | %FileCheck %s -check-prefix=CLOSURE_PARAM_2
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_IIFE_1 | %FileCheck %s -check-prefix=IN_IIFE_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_IIFE_2 | %FileCheck %s -check-prefix=IN_IIFE_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_IIFE_3 | %FileCheck %s -check-prefix=IN_IIFE_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=IN_IIFE_4 | %FileCheck %s -check-prefix=IN_IIFE_1
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=ERROR_IN_CLOSURE_IN_INITIALIZER | %FileCheck %s -check-prefix=ERROR_IN_CLOSURE_IN_INITIALIZER
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DECL_IN_CLOSURE_IN_TOPLEVEL_INIT | %FileCheck %s -check-prefix=DECL_IN_CLOSURE_IN_TOPLEVEL_INIT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SINGLE_EXPR_CLOSURE_CONTEXT | %FileCheck %s -check-prefix=SINGLE_EXPR_CLOSURE_CONTEXT
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT | %FileCheck %s -check-prefix=SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT
// ERROR_COMMON: found code completion token
// ERROR_COMMON-NOT: Begin completions
//===--- Helper types that are used in this test
struct FooStruct {
var instanceVar : Int
func instanceFunc0() {}
}
// FOO_OBJECT_DOT: Begin completions
// FOO_OBJECT_DOT-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
// FOO_OBJECT_DOT-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
// FOO_OBJECT_DOT-NEXT: Decl[InstanceMethod]/CurrNominal{{(/TypeRelation\[Identical\])?}}: instanceFunc0()[#Void#]{{; name=.+$}}
// FOO_OBJECT_DOT-NEXT: End completions
// WITH_GLOBAL_DECLS: Begin completions
// WITH_GLOBAL_DECLS: Decl[Struct]/CurrModule: FooStruct[#FooStruct#]{{; name=.+$}}
// WITH_GLOBAL_DECLS: End completions
//===--- Check that we can resolve closure parameters.
func testResolveClosureParam1() {
var x = { (fs: FooStruct) in fs.#^RESOLVE_CLOSURE_PARAM_1^# }
}
func testResolveClosureParam2() {
{ (fs: FooStruct) in fs.#^RESOLVE_CLOSURE_PARAM_2^# }
}
//===--- Check that we can resolve parent function parameters.
func testResolveParentParam1(_ fs: FooStruct) {
{ (a: Int) in fs.#^RESOLVE_PARENT_PARAM_1^# }
}
func testResolveParentParam2(_ fs: FooStruct) {
{ fs.#^RESOLVE_PARENT_PARAM_2^# }
}
class TestResolveParentParam3 {
func testResolveParentParam3a(_ fs: FooStruct) {
{ (a: Int) in fs.#^RESOLVE_PARENT_PARAM_3^# }
}
}
class TestResolveParentParam4 {
func testResolveParentParam4a(_ fs: FooStruct) {
{ fs.#^RESOLVE_PARENT_PARAM_4^# }
}
}
func testResolveParentParam5(_ fs: FooStruct) {
func testResolveParentParam5a() {
{ fs.#^RESOLVE_PARENT_PARAM_5^# }
}
}
func testResolveParentParam6() {
func testResolveParentParam6a(_ fs: FooStruct) {
{ fs.#^RESOLVE_PARENT_PARAM_6^# }
}
}
//===--- Test completion in various statements in closures.
func testReturnInClosure1() {
var f = { () -> Int in
return #^RETURN_1^#
}
}
//===--- Test that we do delayed parsing of closures.
var topLevelClosure1 = { #^DELAYED_1^# }
var topLevelClosure2 = { func f() { #^DELAYED_2^# } }
var topLevelClosure3 = { class C { func f() { #^DELAYED_3^# } } }
class ClassWithClosureMember1 {
var c1 = { #^DELAYED_4^# }
lazy var c2 = { #^DELAYED_5^# }
var c3 = ({ #^DELAYED_6^# })()
lazy var c4 = ({ #^DELAYED_7^# })()
}
struct NestedStructWithClosureMember1 {
struct Nested {
var c1 = { #^DELAYED_8^# }
lazy var c2 = { #^DELAYED_9^# }
}
}
// WITH_GLOBAL_DECLS_AND_LOCAL1: Begin completions
// WITH_GLOBAL_DECLS_AND_LOCAL1: Decl[LocalVar]/Local: x[#Int#]
// WITH_GLOBAL_DECLS_AND_LOCAL1: Decl[Struct]/CurrModule: FooStruct[#FooStruct#]{{; name=.+$}}
// WITH_GLOBAL_DECLS_AND_LOCAL1: End completions
struct StructWithClosureMemberAndLocal {
var c = {
var x = 0
#^DELAYED_10^#
}
}
func acceptsTrailingClosureFooVoid(_ code: (FooStruct) -> Void) {}
acceptsTrailingClosureFooVoid {
#^IN_TRAILING_CLOSURE_1^#
}
acceptsTrailingClosureFooVoid {
$0.#^IN_TRAILING_CLOSURE_2^#
}
acceptsTrailingClosureFooVoid {
item in #^IN_TRAILING_CLOSURE_3^#
}
acceptsTrailingClosureFooVoid {
item in item.#^IN_TRAILING_CLOSURE_4^#
}
acceptsTrailingClosureFooVoid {
item in
item.instanceFunc0()
item.#^IN_TRAILING_CLOSURE_5^#
}
func acceptsListAndTrailingClosureFooVoid(
_ list: [FooStruct], code: (FooStruct) -> Void) {
}
acceptsListAndTrailingClosureFooVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
#^IN_TRAILING_CLOSURE_6^#
}
acceptsListAndTrailingClosureFooVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
$0.#^IN_TRAILING_CLOSURE_7^#
}
acceptsListAndTrailingClosureFooVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in #^IN_TRAILING_CLOSURE_8^#
}
acceptsListAndTrailingClosureFooVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in item.#^IN_TRAILING_CLOSURE_9^#
}
acceptsListAndTrailingClosureFooVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in
item.instanceFunc0()
item.#^IN_TRAILING_CLOSURE_10^#
}
func acceptsListAndTrailingClosureTVoid<T>(_ list: [T], code: (T) -> Void) {}
acceptsListAndTrailingClosureTVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
#^IN_TRAILING_CLOSURE_11^#
}
acceptsListAndTrailingClosureTVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
$0.#^IN_TRAILING_CLOSURE_12^#
}
acceptsListAndTrailingClosureTVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in #^IN_TRAILING_CLOSURE_13^#
}
acceptsListAndTrailingClosureTVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in item.#^IN_TRAILING_CLOSURE_14^#
}
acceptsListAndTrailingClosureTVoid(
[ FooStruct(instanceVar: 0), FooStruct(instanceVar: 0) ]) {
item in
item.instanceFunc0()
item.#^IN_TRAILING_CLOSURE_15^#
}
func getInt() -> Int? { return 0 }
func testAcceptsTrailingClosureInt1() {
acceptsTrailingClosureFooVoid { #^IN_TRAILING_CLOSURE_16^# in
if let myvar = getInt() {
}
}
}
func testAcceptsTrailingClosureInt2() {
acceptsTrailingClosureFooVoid {
#^IN_TRAILING_CLOSURE_17^#
if let myvar = getInt() {
}
}
}
func testAcceptsTrailingClosureInt3() {
acceptsTrailingClosureFooVoid {
if let myvar = getInt() {
}
#^IN_TRAILING_CLOSURE_18^#
}
}
func testAcceptsTrailingClosureInt4() {
acceptsTrailingClosureFooVoid {
if let myvar = getInt() {
#^IN_TRAILING_CLOSURE_19^#
}
}
}
func testTypeInClosure1() {
acceptsTrailingClosureFooVoid {
struct S : #^STRUCT_INHERITANCE_IN_CLOSURE_0^#
}
}
func testTypeInClosure2() {
acceptsTrailingClosureFooVoid {
class S : #^CLASS_INHERITANCE_IN_CLOSURE_0^#
}
}
func testTypeInClosure3() {
acceptsTrailingClosureFooVoid {
func test(_ x: #^ARGUMENT_TYPE_IN_CLOSURE_0^#
}
}
acceptsTrailingClosureFooVoid {
struct S : #^STRUCT_INHERITANCE_IN_CLOSURE_1^#
}
acceptsTrailingClosureFooVoid {
class S : #^CLASS_INHERITANCE_IN_CLOSURE_1^#
}
acceptsTrailingClosureFooVoid {
func test(_ x: #^ARGUMENT_TYPE_IN_CLOSURE_1^#
}
struct LazyVar1 {
lazy var x: Int = {
struct S : #^STRUCT_INHERITANCE_IN_CLOSURE_2^#
}()
}
struct LazyVar2 {
lazy var x: Int = {
class S : #^CLASS_INHERITANCE_IN_CLOSURE_2^#
}()
}
struct LazyVar3 {
lazy var x: Int = {
func test(_ x: #^ARGUMENT_TYPE_IN_CLOSURE_2^#
}()
}
func closureTaker(_ theFunc:(theValue: Int) -> ()) {}
func closureTaker2(_ theFunc: (Value1: Int, Value2: Int) -> ()) {}
func testClosureParam1() {
closureTaker { (theValue) -> () in
#^CLOSURE_PARAM_1^#
}
}
// CLOSURE_PARAM_1: Begin completions
// CLOSURE_PARAM_1-DAG: Decl[LocalVar]/Local: theValue[#Int#]{{; name=.+$}}
func testClosureParam2() {
closureTaker2 { (Value1, Value2) -> () in
#^CLOSURE_PARAM_2^#
}
}
// CLOSURE_PARAM_2: Begin completions
// CLOSURE_PARAM_2-DAG: Decl[LocalVar]/Local: Value1[#Int#]{{; name=.+$}}
// CLOSURE_PARAM_2-DAG: Decl[LocalVar]/Local: Value2[#Int#]{{; name=.+$}}
enum SomeEnum {
case north, south
}
struct BarStruct {
var enumVal: SomeEnum = .north
}
var testIIFEVar: BarStruct = {
var obj = BarStruct()
obj.enumVal = .#^IN_IIFE_1^#
return obj
}()
testIIFEVar = {
var obj = BarStruct()
obj.enumVal = .#^IN_IIFE_2^#
return obj
}()
func testIIFE() {
var testIIFEVar: FooStruct = {
var obj = BarStruct()
obj.enumVal = .#^IN_IIFE_3^#
return obj
}()
testIIFEVar = {
var obj = BarStruct()
obj.enumVal = .#^IN_IIFE_4^#
return obj
}()
}
// IN_IIFE_1: Begin completions
// IN_IIFE_1-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Identical]: north[#SomeEnum#]
// IN_IIFE_1-DAG: Decl[EnumElement]/ExprSpecific/TypeRelation[Identical]: south[#SomeEnum#]
extension Error {
var myErrorNumber: Int { return 0 }
}
class C {
var foo: String = {
do {
} catch {
error.#^ERROR_IN_CLOSURE_IN_INITIALIZER^#
// ERROR_IN_CLOSURE_IN_INITIALIZER: Begin completions
// ERROR_IN_CLOSURE_IN_INITIALIZER-DAG: Keyword[self]/CurrNominal: self[#Error#]; name=self
// ERROR_IN_CLOSURE_IN_INITIALIZER-DAG: Decl[InstanceVar]/CurrNominal: myErrorNumber[#Int#]; name=myErrorNumber
// ERROR_IN_CLOSURE_IN_INITIALIZER: End completions
}
return ""
}()
}
var foo = {
let x = "Siesta:\(3)".#^DECL_IN_CLOSURE_IN_TOPLEVEL_INIT^#
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT: Begin completions
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Keyword[self]/CurrNominal: self[#String#]; name=self
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Decl[InstanceVar]/CurrNominal: count[#Int#]; name=count
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Decl[InstanceVar]/CurrNominal: unicodeScalars[#String.UnicodeScalarView#]; name=unicodeScalars
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Decl[InstanceMethod]/CurrNominal: hasPrefix({#(prefix): String#})[#Bool#]; name=hasPrefix(prefix: String)
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Decl[InstanceVar]/CurrNominal: utf16[#String.UTF16View#]; name=utf16
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT-DAG: Decl[InstanceMethod]/Super: dropFirst()[#Substring#]; name=dropFirst()
// DECL_IN_CLOSURE_IN_TOPLEVEL_INIT: End completions
}
func testWithMemoryRebound(_ bar: UnsafePointer<UInt64>) {
_ = bar.withMemoryRebound(to: Int64.self, capacity: 3) { ptr in
return ptr #^SINGLE_EXPR_CLOSURE_CONTEXT^#
// SINGLE_EXPR_CLOSURE_CONTEXT: Begin completions
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceMethod]/CurrNominal: .deallocate()[#Void#]; name=deallocate()
// SINGLE_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal: .pointee[#Int64#]; name=pointee
// SINGLE_EXPR_CLOSURE_CONTEXT: End completions
}
}
func testInsideTernaryClosureReturn(test: Bool) -> [String] {
return "hello".map { thing in
test ? String(thing #^SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT^#).uppercased() : String(thing).lowercased()
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT: Begin completions
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal: .utf8[#Character.UTF8View#]; name=utf8
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal: .description[#String#]; name=description
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceVar]/CurrNominal: .isWhitespace[#Bool#]; name=isWhitespace
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InstanceMethod]/CurrNominal: .uppercased()[#String#]; name=uppercased()
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']... {#String.Element#}[#ClosedRange<String.Element>#]; name=... String.Element
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']< {#Character#}[#Bool#]; name=< Character
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']>= {#String.Element#}[#Bool#]; name=>= String.Element
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']== {#Character#}[#Bool#]; name=== Character
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT-DAG: Keyword[self]/CurrNominal: .self[#String.Element#]; name=self
// SINGLE_TERNARY_EXPR_CLOSURE_CONTEXT: End completions
}
}