@@ -18,6 +18,40 @@ func testGlobalFunc() {
18
18
// GLOBALFUNC_AFTERLABEL-NOT: Begin completions
19
19
}
20
20
21
+ struct S {
22
+ func member( ) { }
23
+ }
24
+ func globalFunc2( x: Int = 0 , _ fn: ( ) -> Void ) -> S { }
25
+ func globalFunc3( x: Int , _ fn: ( ) -> Void ) -> S { }
26
+
27
+ func testNonFuncArg( ) {
28
+ do {
29
+ // Don't complete for a non-function default argument.
30
+ globalFunc2 { } #^GLOBALFUNC2^#
31
+ // GLOBALFUNC2: Begin completions, 2 items
32
+ // GLOBALFUNC2-DAG: Decl[InstanceMethod]/CurrNominal: .member()[#Void#]; name=member()
33
+ // GLOBALFUNC2-DAG: Keyword[self]/CurrNominal: .self[#S#]; name=self
34
+
35
+ globalFunc2 { }
36
+ . #^GLOBALFUNC2_DOT^#
37
+ // GLOBALFUNC2_DOT: Begin completions, 2 items
38
+ // GLOBALFUNC2_DOT-DAG: Decl[InstanceMethod]/CurrNominal: member()[#Void#]; name=member()
39
+ // GLOBALFUNC2_DOT-DAG: Keyword[self]/CurrNominal: self[#S#]; name=self
40
+ }
41
+ do {
42
+ globalFunc3 { } #^GLOBALFUNC3^#
43
+ // GLOBALFUNC3: Begin completions, 2 items
44
+ // GLOBALFUNC3-DAG: Decl[InstanceMethod]/CurrNominal: .member()[#Void#]; name=member()
45
+ // GLOBALFUNC3-DAG: Keyword[self]/CurrNominal: .self[#S#]; name=self
46
+
47
+ globalFunc3 { }
48
+ . #^GLOBALFUNC3_DOT^#
49
+ // GLOBALFUNC3_DOT: Begin completions, 2 items
50
+ // GLOBALFUNC3_DOT-DAG: Decl[InstanceMethod]/CurrNominal: member()[#Void#]; name=member()
51
+ // GLOBALFUNC3_DOT-DAG: Keyword[self]/CurrNominal: self[#S#]; name=self
52
+ }
53
+ }
54
+
21
55
struct SimpleEnum {
22
56
case foo, bar
23
57
@@ -99,6 +133,17 @@ func testOptionalInit() {
99
133
// INIT_OPTIONAL_NEWLINE-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
100
134
}
101
135
136
+ func testOptionalInitDot( ) {
137
+ // When there's a dot, we don't complete for the closure argument.
138
+ TestStruct2 {
139
+ 2
140
+ }
141
+ . #^INIT_OPTIONAL_DOT^#
142
+ // INIT_OPTIONAL_DOT: Begin completions, 2 items
143
+ // INIT_OPTIONAL_DOT-DAG: Keyword[self]/CurrNominal: self[#TestStruct2#]; name=self
144
+ // INIT_OPTIONAL_DOT-DAG: Decl[InstanceMethod]/CurrNominal: testStructMethod()[#Void#]; name=testStructMethod()
145
+ }
146
+
102
147
struct TestStruct3 {
103
148
init ( fn1: ( ) -> Int , fn2: ( ) -> String , fn3: ( ) -> String ) { }
104
149
func testStructMethod( ) { }
@@ -171,10 +216,9 @@ func testFallbackPostfix() {
171
216
let _ = MyStruct4 {
172
217
1
173
218
} #^INIT_FALLBACK_1^#
174
- // INIT_FALLBACK_1: Begin completions, 3 items
219
+ // INIT_FALLBACK_1: Begin completions, 2 items
175
220
// INIT_FALLBACK_1-DAG: Keyword[self]/CurrNominal: .self[#MyStruct4<Int>#]; name=self
176
221
// INIT_FALLBACK_1-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Invalid]: .testStructMethod()[#Void#]; name=testStructMethod()
177
- // INIT_FALLBACK_1-DAG: Pattern/Local/Flair[ArgLabels]: {#arg1: Int#}[#Int#]; name=arg1:
178
222
let _ = MyStruct4 ( name: " test " ) {
179
223
" "
180
224
} arg3: {
0 commit comments