Skip to content

Commit 7b41a41

Browse files
committed
updated tests & added completions for postfixExpr
1 parent c88e1c9 commit 7b41a41

34 files changed

+219
-70
lines changed

lib/IDE/CodeCompletion.cpp

+22-14
Original file line numberDiff line numberDiff line change
@@ -2838,23 +2838,29 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
28382838
}
28392839

28402840
void addKeyword(StringRef Name, Type TypeAnnotation,
2841-
SemanticContextKind SK = SemanticContextKind::None) {
2841+
SemanticContextKind SK = SemanticContextKind::None,
2842+
CodeCompletionKeywordKind KeyKind
2843+
= CodeCompletionKeywordKind::None) {
28422844
CodeCompletionResultBuilder Builder(
28432845
Sink,
28442846
CodeCompletionResult::ResultKind::Keyword, SK, ExpectedTypes);
28452847
addLeadingDot(Builder);
28462848
Builder.addTextChunk(Name);
2849+
Builder.setKeywordKind(KeyKind);
28472850
if (!TypeAnnotation.isNull())
28482851
addTypeAnnotation(Builder, TypeAnnotation);
28492852
}
28502853

2851-
void addKeyword(StringRef Name, StringRef TypeAnnotation) {
2854+
void addKeyword(StringRef Name, StringRef TypeAnnotation,
2855+
CodeCompletionKeywordKind KeyKind
2856+
= CodeCompletionKeywordKind::None) {
28522857
CodeCompletionResultBuilder Builder(
28532858
Sink,
28542859
CodeCompletionResult::ResultKind::Keyword,
28552860
SemanticContextKind::None, ExpectedTypes);
28562861
addLeadingDot(Builder);
28572862
Builder.addTextChunk(Name);
2863+
Builder.setKeywordKind(KeyKind);
28582864
if (!TypeAnnotation.empty())
28592865
Builder.addTypeAnnotation(TypeAnnotation);
28602866
}
@@ -3259,14 +3265,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
32593265
ExprType = ExprType->getRValueType();
32603266
this->ExprType = ExprType;
32613267
if (ExprType->hasTypeParameter()) {
3262-
DeclContext *DC;
3263-
if (VD) {
3268+
DeclContext *DC = nullptr;
3269+
if (VD)
32643270
DC = VD->getInnermostDeclContext();
3265-
this->ExprType = DC->mapTypeIntoContext(ExprType);
3266-
} else if (auto NTD = ExprType->getRValueInstanceType()->getAnyNominal()) {
3271+
else if (auto NTD = ExprType->getRValueInstanceType()->getAnyNominal())
32673272
DC = NTD;
3268-
this->ExprType = DC->mapTypeIntoContext(ExprType);
3269-
}
3273+
if (DC)
3274+
ExprType = DC->mapTypeIntoContext(ExprType);
32703275
}
32713276

32723277
// Handle special cases
@@ -5318,12 +5323,10 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53185323
if (isDynamicLookup(*ExprType))
53195324
Lookup.setIsDynamicLookup();
53205325

5321-
CodeCompletionResultBuilder Builder(CompletionContext.getResultSink(),
5322-
CodeCompletionResult::ResultKind::Keyword,
5323-
SemanticContextKind::CurrentNominal, {});
5324-
Builder.setKeywordKind(CodeCompletionKeywordKind::kw_self);
5325-
Builder.addTextChunk("self");
5326-
Builder.addTypeAnnotation(ExprType->getString());
5326+
if (!ExprType.getValue()->getAs<ModuleType>())
5327+
Lookup.addKeyword("self", (*ExprType)->getRValueType(),
5328+
SemanticContextKind::CurrentNominal,
5329+
CodeCompletionKeywordKind::kw_self);
53275330

53285331
if (isa<BindOptionalExpr>(ParsedExpr) || isa<ForceValueExpr>(ParsedExpr))
53295332
Lookup.setIsUnwrappedOptional(true);
@@ -5373,6 +5376,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
53735376
Lookup.setIsDynamicLookup();
53745377
Lookup.getValueExprCompletions(*ExprType, ReferencedDecl.getDecl());
53755378
Lookup.getOperatorCompletions(ParsedExpr, leadingSequenceExprs);
5379+
5380+
if (!ExprType.getValue()->getAs<ModuleType>())
5381+
Lookup.addKeyword("self", (*ExprType)->getRValueType(),
5382+
SemanticContextKind::CurrentNominal,
5383+
CodeCompletionKeywordKind::kw_self);
53765384
break;
53775385
}
53785386

test/IDE/complete_after_self.swift

+11-7
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class ThisDerived1 : ThisBase1 {
166166

167167
init() {
168168
self#^CONSTRUCTOR_SELF_NO_DOT_1^#
169-
// CONSTRUCTOR_SELF_NO_DOT_1: Begin completions, 23 items
169+
// CONSTRUCTOR_SELF_NO_DOT_1: Begin completions, 24 items
170170
// CONSTRUCTOR_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init()[#ThisDerived1#];
171171
// CONSTRUCTOR_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init({#a: Int#})[#ThisDerived1#];
172172
// CONSTRUCTOR_SELF_NO_DOT_1: End completions
@@ -177,33 +177,34 @@ class ThisDerived1 : ThisBase1 {
177177

178178
init(a : Int) {
179179
self.#^CONSTRUCTOR_SELF_DOT_1^#
180-
// CONSTRUCTOR_SELF_DOT_1: Begin completions, 18 items
180+
// CONSTRUCTOR_SELF_DOT_1: Begin completions, 19 items
181181
// CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#ThisDerived1#];
182182
// CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ThisDerived1#];
183+
183184
// CONSTRUCTOR_SELF_DOT_1: End completions
184185
let d: ThisDerived1
185186
d.#^CONSTRUCTOR_NONSELF_DOT_1^#
186187
}
187188

188189
deinit {
189190
self#^DESTRUCTOR_SELF_NO_DOT_1^#
190-
// DESTRUCTOR_SELF_NO_DOT_1: Begin completions, 20 items
191+
// DESTRUCTOR_SELF_NO_DOT_1: Begin completions, 21 items
191192
// DESTRUCTOR_SELF_NO_DOT_1: End completions
192193

193194
self.#^DESTRUCTOR_SELF_DOT_1^#
194-
// DESTRUCTOR_SELF_DOT_1: Begin completions, 15 items
195+
// DESTRUCTOR_SELF_DOT_1: Begin completions, 16 items
195196
// DESTRUCTOR_SELF_DOT_1: End completions
196197
}
197198

198199
func test1() {
199200
self#^FUNC_SELF_NO_DOT_1^#
200-
// FUNC_SELF_NO_DOT_1: Begin completions, 20 items
201+
// FUNC_SELF_NO_DOT_1: Begin completions, 21 items
201202
// FUNC_SELF_NO_DOT_1: End completions
202203
}
203204

204205
func test2() {
205206
self.#^FUNC_SELF_DOT_1^#
206-
// FUNC_SELF_DOT_1: Begin completions, 15 items
207+
// FUNC_SELF_DOT_1: Begin completions, 16 items
207208
// FUNC_SELF_DOT_1: End completions
208209
}
209210

@@ -236,12 +237,14 @@ class ThisDerived1 : ThisBase1 {
236237
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[Class]/Super: .BaseExtNestedClass[#ThisBase1.BaseExtNestedClass#]
237238
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[Enum]/Super: .BaseExtNestedEnum[#ThisBase1.BaseExtNestedEnum#]
238239
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[TypeAlias]/Super: .BaseExtNestedTypealias[#Int#]
240+
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Keyword[self]/CurrNominal: .self[#ThisDerived1.Type#]; name=self
239241
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: End completions
240242
}
241243

242244
class func staticTest2() {
243245
self.#^FUNC_STATIC_SELF_DOT_1^#
244246
// FUNC_STATIC_SELF_DOT_1: Begin completions
247+
// FUNC_STATIC_SELF_DOT_1-NEXT: Keyword[self]/CurrNominal: self[#ThisDerived1.Type#]; name=self
245248
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[InstanceMethod]/CurrNominal: derivedFunc0({#self: ThisDerived1#})[#() -> Void#]
246249
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[StaticVar]/CurrNominal: derivedStaticVar[#Int#]
247250
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[StaticMethod]/CurrNominal: derivedStaticFunc0()[#Void#]
@@ -307,7 +310,8 @@ struct S1 {
307310
init() {}
308311
init(x: Int) {
309312
self.#^STRUCT_CONSTRUCTOR_SELF_DOT_1^#
310-
// STRUCT_CONSTRUCTOR_SELF_DOT_1: Begin completions, 3 items
313+
// STRUCT_CONSTRUCTOR_SELF_DOT_1: Begin completions, 4 items
314+
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Keyword[self]/CurrNominal: self[#S1#]; name=self
311315
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#S1#];
312316
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#x: Int#})[#S1#];
313317
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: f()[#Void#];

test/IDE/complete_associated_types.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func testStruct3(a: StructWithAssociatedTypes) {
179179
}
180180
// STRUCT_TYPE_COUNT: Begin completions, 26 items
181181

182-
// STRUCT_INSTANCE: Begin completions, 14 items
182+
// STRUCT_INSTANCE: Begin completions, 15 items
183183
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonA()[#Int#]
184184
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonB()[#Int#]
185185
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonC()[#Int#]
@@ -194,6 +194,7 @@ func testStruct3(a: StructWithAssociatedTypes) {
194194
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarBaseC()[#Int#]
195195
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarBaseD()[#Int#]
196196
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarD()[#Int#]
197+
// STRUCT_INSTANCE-DAG: Keyword[self]/CurrNominal: self[#StructWithAssociatedTypes#]; name=self
197198
// STRUCT_INSTANCE: End completions
198199

199200
// STRUCT_TYPES: Begin completions
@@ -266,7 +267,7 @@ struct StructWithBrokenConformance : FooProtocolWithAssociatedTypes {
266267
func testBrokenConformances1() {
267268
StructWithBrokenConformance.#^BROKEN_CONFORMANCE_1^#
268269
}
269-
// BROKEN_CONFORMANCE_1: Begin completions, 34 items
270+
// BROKEN_CONFORMANCE_1: Begin completions, 35 items
270271
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonA[#StructWithBrokenConformance.DefaultedTypeCommonA#]; name=DefaultedTypeCommonA
271272
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonB[#StructWithBrokenConformance.DefaultedTypeCommonB#]; name=DefaultedTypeCommonB
272273
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: FooBaseDefaultedTypeB[#StructWithBrokenConformance.FooBaseDefaultedTypeB#]; name=FooBaseDefaultedTypeB

test/IDE/complete_at_top_level.swift

+8-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ fooObject#^TYPE_CHECKED_EXPR_1^#
178178
// TYPE_CHECKED_EXPR_1: Begin completions
179179
// TYPE_CHECKED_EXPR_1-NEXT: Decl[InstanceVar]/CurrNominal: .instanceVar[#Int#]{{; name=.+$}}
180180
// TYPE_CHECKED_EXPR_1-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
181-
// TYPE_CHECKED_EXPR_1-NEXT:BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
181+
// TYPE_CHECKED_EXPR_1-NEXT: BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
182+
// TYPE_CHECKED_EXPR_1-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct#]; name=self
182183
// TYPE_CHECKED_EXPR_1-NEXT: End completions
183184

184185
func resyncParser2() {}
@@ -191,6 +192,7 @@ fooObject#^TYPE_CHECKED_EXPR_2^#
191192
// TYPE_CHECKED_EXPR_2-NEXT: Decl[InstanceVar]/CurrNominal: .instanceVar[#Int#]{{; name=.+$}}
192193
// TYPE_CHECKED_EXPR_2-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
193194
// TYPE_CHECKED_EXPR_2-NEXT: BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
195+
// TYPE_CHECKED_EXPR_2-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct#]; name=self
194196
// TYPE_CHECKED_EXPR_2-NEXT: End completions
195197

196198
func resyncParser3() {}
@@ -200,12 +202,14 @@ fooObject#^TYPE_CHECKED_EXPR_3^#.bar
200202
// TYPE_CHECKED_EXPR_3-NEXT: Decl[InstanceVar]/CurrNominal: .instanceVar[#Int#]{{; name=.+$}}
201203
// TYPE_CHECKED_EXPR_3-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
202204
// TYPE_CHECKED_EXPR_3-NEXT: BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
205+
// TYPE_CHECKED_EXPR_3-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct#]; name=self
203206
// TYPE_CHECKED_EXPR_3-NEXT: End completions
204207

205208
func resyncParser4() {}
206209

207210
fooObject.#^TYPE_CHECKED_EXPR_4^#
208211
// TYPE_CHECKED_EXPR_4: Begin completions
212+
// TYPE_CHECKED_EXPR_4-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
209213
// TYPE_CHECKED_EXPR_4-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
210214
// TYPE_CHECKED_EXPR_4-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
211215
// TYPE_CHECKED_EXPR_4-NEXT: End completions
@@ -214,6 +218,7 @@ func resyncParser5() {}
214218

215219
fooObject.#^TYPE_CHECKED_EXPR_5^#.bar
216220
// TYPE_CHECKED_EXPR_5: Begin completions
221+
// TYPE_CHECKED_EXPR_5-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
217222
// TYPE_CHECKED_EXPR_5-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
218223
// TYPE_CHECKED_EXPR_5-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
219224
// TYPE_CHECKED_EXPR_5-NEXT: End completions
@@ -236,6 +241,7 @@ var fooObjectWithErrorInInit : FooStruct = unknown_var
236241

237242
fooObjectWithErrorInInit.#^TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1^#
238243
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1: Begin completions
244+
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
239245
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
240246
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
241247
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: End completions
@@ -259,6 +265,7 @@ var topLevelVar2 = FooStruct#^TOP_LEVEL_VAR_INIT_2^#
259265
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#self: FooStruct#})[#(Int) -> Void#]{{; name=.+$}}
260266
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#FooStruct#]{{; name=.+$}}
261267
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ()[#FooStruct#]{{; name=.+$}}
268+
// TOP_LEVEL_VAR_INIT_2-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct.Type#]; name=self
262269
// TOP_LEVEL_VAR_INIT_2-NEXT: End completions
263270

264271
func resyncParser8() {}

test/IDE/complete_call_arg.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ class Bar {
413413
self.collectionView? .#^BOUND_IUO^#x
414414
self.collectionView! .#^FORCED_IUO^#x
415415
}
416-
// MEMBEROF_IUO: Begin completions, 1 items
416+
// MEMBEROF_IUO: Begin completions, 2 items
417+
// MEMBEROF_IUO: Keyword[self]/CurrNominal: self[#Foo#]; name=self
417418
// MEMBEROF_IUO: Decl[InstanceVar]/CurrNominal: x[#Int#]; name=x
418419
// MEMBEROF_IUO: End completions
419420
}

test/IDE/complete_constructor.swift

+15-7
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ struct ImplicitConstructors1 {
4343

4444
func testImplicitConstructors1() {
4545
ImplicitConstructors1#^IMPLICIT_CONSTRUCTORS_1^#
46-
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 1 items
46+
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 2 items
4747
// IMPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors1#]{{; name=.+$}}
48+
// IMPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors1.Type#]; name=self
4849
// IMPLICIT_CONSTRUCTORS_1: End completions
4950
}
5051
func testImplicitConstructors1P() {
@@ -58,9 +59,10 @@ struct ImplicitConstructors2 {
5859

5960
func testImplicitConstructors2() {
6061
ImplicitConstructors2#^IMPLICIT_CONSTRUCTORS_2^#
61-
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 2 items
62+
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 3 items
6263
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#ImplicitConstructors2#]{{; name=.+$}}
6364
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors2#]{{; name=.+$}}
65+
// IMPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors2.Type#]; name=self
6466
// IMPLICIT_CONSTRUCTORS_2: End completions
6567
}
6668
func testImplicitConstructors2P() {
@@ -78,10 +80,11 @@ struct ExplicitConstructors1 {
7880

7981
func testExplicitConstructors1() {
8082
ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_1^#
81-
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 3 items
83+
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 4 items
8284
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]{{; name=.+$}}
8385
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]{{; name=.+$}}
8486
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]{{; name=.+$}}
87+
// EXPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
8588
// EXPLICIT_CONSTRUCTORS_1: End completions
8689
}
8790
func testExplicitConstructors1P() {
@@ -94,10 +97,11 @@ func testExplicitConstructors1P() {
9497

9598
ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_2^#
9699

97-
// EXPLICIT_CONSTRUCTORS_2: Begin completions, 3 items
100+
// EXPLICIT_CONSTRUCTORS_2: Begin completions, 4 items
98101
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]
99102
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]
100103
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]
104+
// EXPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
101105
// EXPLICIT_CONSTRUCTORS_2: End completions
102106

103107
ExplicitConstructors1(#^EXPLICIT_CONSTRUCTORS_2P^#
@@ -130,9 +134,10 @@ struct ExplicitConstructorsSelector1 {
130134

131135
func testExplicitConstructorsSelector1() {
132136
ExplicitConstructorsSelector1#^EXPLICIT_CONSTRUCTORS_SELECTOR_1^#
133-
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 2 items
137+
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 3 items
134138
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
135139
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#andFloat: Float#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
140+
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector1.Type#]; name=self
136141
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: End completions
137142
}
138143

@@ -145,11 +150,12 @@ struct ExplicitConstructorsSelector2 {
145150

146151
func testExplicitConstructorsSelector2() {
147152
ExplicitConstructorsSelector2#^EXPLICIT_CONSTRUCTORS_SELECTOR_2^#
148-
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 4 items
153+
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 5 items
149154
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#noArgs: ()#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
150155
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
151156
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#}, {#withFloat: Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
152157
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
158+
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector2.Type#]; name=self
153159
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: End completions
154160
}
155161

@@ -174,16 +180,18 @@ class ExplicitConstructorsDerived2 : ExplicitConstructorsBase1 {
174180
func testExplicitConstructorsBaseDerived1() {
175181
ExplicitConstructorsDerived1#^EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1^#
176182
}
177-
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 2 items
183+
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 3 items
178184
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructorsDerived1#]{{; name=.+$}}
179185
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructorsDerived1#]{{; name=.+$}}
186+
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsDerived1.Type#]; name=self
180187
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: End completions
181188

182189
func testGetInitFromMetatype1() {
183190
ExplicitConstructorsBase1.#^INIT_FROM_METATYPE1^#
184191
}
185192

186193
// INIT_FROM_METATYPE1: Begin completions
194+
// INIT_FROM_METATYPE1-NEXT: Keyword[self]/CurrNominal: self[#ExplicitConstructorsBase1.Type#]; name=self
187195
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init()[#ExplicitConstructorsBase1#]{{; name=.+$}}
188196
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ExplicitConstructorsBase1#]{{; name=.+$}}
189197
// INIT_FROM_METATYPE1-NEXT: End completions

test/IDE/complete_crashes.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ protocol BadMembers2 {
3030
func badMembers2(_ a: BadMembers2) {
3131
a#^BAD_MEMBERS_2^#
3232
}
33-
// BAD_MEMBERS_2: Begin completions, 2 items
33+
// BAD_MEMBERS_2: Begin completions, 3 items
3434
// BAD_MEMBERS_2-NEXT: Decl[InstanceVar]/CurrNominal: .prop[#Int#]{{; name=.+$}}
3535
// BAD_MEMBERS_2-NEXT: Decl[Subscript]/CurrNominal: [{#Int#}][#Double#]{{; name=.+$}}
36+
// BAD_MEMBERS_2-NEXT: Keyword[self]/CurrNominal: .self[#BadMembers2#]; name=self
3637
// BAD_MEMBERS_2-NEXT: End completions
3738

3839
func globalFunc() {}
@@ -220,10 +221,11 @@ protocol Bar_38149042 {
220221
func foo_38149042(bar: Bar_38149042) {
221222
_ = bar.foo? #^RDAR_38149042^# .x
222223
}
223-
// RDAR_38149042: Begin completions, 3 items
224+
// RDAR_38149042: Begin completions, 4 items
224225
// RDAR_38149042-DAG: Decl[InstanceVar]/CurrNominal: .x[#Int#]; name=x
225226
// RDAR_38149042-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']=== {#AnyObject?#}[#Bool#]; name==== AnyObject?
226227
// RDAR_38149042-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']!== {#AnyObject?#}[#Bool#]; name=!== AnyObject?
228+
// RDAR_38149042-DAG: Keyword[self]/CurrNominal: .self[#Baz_38149042#]; name=self
227229
// RDAR_38149042: End completions
228230

229231
// rdar://problem/38272904

0 commit comments

Comments
 (0)