@@ -18,6 +18,40 @@ func testGlobalFunc() {
1818// GLOBALFUNC_AFTERLABEL-NOT: Begin completions
1919}
2020
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+
2155struct SimpleEnum {
2256 case foo, bar
2357
@@ -99,6 +133,17 @@ func testOptionalInit() {
99133// INIT_OPTIONAL_NEWLINE-DAG: Decl[Struct]/CurrModule: MyStruct[#MyStruct#]; name=MyStruct
100134}
101135
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+
102147struct TestStruct3 {
103148 init ( fn1: ( ) -> Int , fn2: ( ) -> String , fn3: ( ) -> String ) { }
104149 func testStructMethod( ) { }
@@ -171,10 +216,9 @@ func testFallbackPostfix() {
171216 let _ = MyStruct4 {
172217 1
173218 } #^INIT_FALLBACK_1^#
174- // INIT_FALLBACK_1: Begin completions, 3 items
219+ // INIT_FALLBACK_1: Begin completions, 2 items
175220// INIT_FALLBACK_1-DAG: Keyword[self]/CurrNominal: .self[#MyStruct4<Int>#]; name=self
176221// 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:
178222 let _ = MyStruct4 ( name: " test " ) {
179223 " "
180224 } arg3: {
0 commit comments