Skip to content

[CodeCompletion] SR-943 'self' for dot expressions #16534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions lib/IDE/CodeCompletion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ class CodeCompletionCallbacksImpl : public CodeCompletionCallbacks {
if (!DC)
return;
auto *CD = DC->getAsClassOrClassExtensionContext();
if (CD == nullptr)
if (!CD)
return;
Type ST = CD->getSuperclass();
if (ST.isNull() || ST->is<ErrorType>())
Expand Down Expand Up @@ -2838,23 +2838,29 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
}

void addKeyword(StringRef Name, Type TypeAnnotation,
SemanticContextKind SK = SemanticContextKind::None) {
SemanticContextKind SK = SemanticContextKind::None,
CodeCompletionKeywordKind KeyKind
= CodeCompletionKeywordKind::None) {
CodeCompletionResultBuilder Builder(
Sink,
CodeCompletionResult::ResultKind::Keyword, SK, ExpectedTypes);
addLeadingDot(Builder);
Builder.addTextChunk(Name);
Builder.setKeywordKind(KeyKind);
if (!TypeAnnotation.isNull())
addTypeAnnotation(Builder, TypeAnnotation);
}

void addKeyword(StringRef Name, StringRef TypeAnnotation) {
void addKeyword(StringRef Name, StringRef TypeAnnotation,
CodeCompletionKeywordKind KeyKind
= CodeCompletionKeywordKind::None) {
CodeCompletionResultBuilder Builder(
Sink,
CodeCompletionResult::ResultKind::Keyword,
SemanticContextKind::None, ExpectedTypes);
addLeadingDot(Builder);
Builder.addTextChunk(Name);
Builder.setKeywordKind(KeyKind);
if (!TypeAnnotation.empty())
Builder.addTypeAnnotation(TypeAnnotation);
}
Expand Down Expand Up @@ -3259,14 +3265,13 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
ExprType = ExprType->getRValueType();
this->ExprType = ExprType;
if (ExprType->hasTypeParameter()) {
DeclContext *DC;
if (VD) {
DeclContext *DC = nullptr;
if (VD)
DC = VD->getInnermostDeclContext();
this->ExprType = DC->mapTypeIntoContext(ExprType);
} else if (auto NTD = ExprType->getRValueInstanceType()->getAnyNominal()) {
else if (auto NTD = ExprType->getRValueInstanceType()->getAnyNominal())
DC = NTD;
this->ExprType = DC->mapTypeIntoContext(ExprType);
}
if (DC)
ExprType = DC->mapTypeIntoContext(ExprType);
}

// Handle special cases
Expand Down Expand Up @@ -5318,6 +5323,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
if (isDynamicLookup(*ExprType))
Lookup.setIsDynamicLookup();

if (!ExprType.getValue()->getAs<ModuleType>())
Lookup.addKeyword("self", (*ExprType)->getRValueType(),
SemanticContextKind::CurrentNominal,
CodeCompletionKeywordKind::kw_self);

if (isa<BindOptionalExpr>(ParsedExpr) || isa<ForceValueExpr>(ParsedExpr))
Lookup.setIsUnwrappedOptional(true);

Expand Down Expand Up @@ -5366,6 +5376,11 @@ void CodeCompletionCallbacksImpl::doneParsing() {
Lookup.setIsDynamicLookup();
Lookup.getValueExprCompletions(*ExprType, ReferencedDecl.getDecl());
Lookup.getOperatorCompletions(ParsedExpr, leadingSequenceExprs);

if (!ExprType.getValue()->getAs<ModuleType>())
Lookup.addKeyword("self", (*ExprType)->getRValueType(),
SemanticContextKind::CurrentNominal,
CodeCompletionKeywordKind::kw_self);
break;
}

Expand Down
18 changes: 11 additions & 7 deletions test/IDE/complete_after_self.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class ThisDerived1 : ThisBase1 {

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

init(a : Int) {
self.#^CONSTRUCTOR_SELF_DOT_1^#
// CONSTRUCTOR_SELF_DOT_1: Begin completions, 18 items
// CONSTRUCTOR_SELF_DOT_1: Begin completions, 19 items
// CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#ThisDerived1#];
// CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ThisDerived1#];

// CONSTRUCTOR_SELF_DOT_1: End completions
let d: ThisDerived1
d.#^CONSTRUCTOR_NONSELF_DOT_1^#
}

deinit {
self#^DESTRUCTOR_SELF_NO_DOT_1^#
// DESTRUCTOR_SELF_NO_DOT_1: Begin completions, 20 items
// DESTRUCTOR_SELF_NO_DOT_1: Begin completions, 21 items
// DESTRUCTOR_SELF_NO_DOT_1: End completions

self.#^DESTRUCTOR_SELF_DOT_1^#
// DESTRUCTOR_SELF_DOT_1: Begin completions, 15 items
// DESTRUCTOR_SELF_DOT_1: Begin completions, 16 items
// DESTRUCTOR_SELF_DOT_1: End completions
}

func test1() {
self#^FUNC_SELF_NO_DOT_1^#
// FUNC_SELF_NO_DOT_1: Begin completions, 20 items
// FUNC_SELF_NO_DOT_1: Begin completions, 21 items
// FUNC_SELF_NO_DOT_1: End completions
}

func test2() {
self.#^FUNC_SELF_DOT_1^#
// FUNC_SELF_DOT_1: Begin completions, 15 items
// FUNC_SELF_DOT_1: Begin completions, 16 items
// FUNC_SELF_DOT_1: End completions
}

Expand Down Expand Up @@ -236,12 +237,14 @@ class ThisDerived1 : ThisBase1 {
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[Class]/Super: .BaseExtNestedClass[#ThisBase1.BaseExtNestedClass#]
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[Enum]/Super: .BaseExtNestedEnum[#ThisBase1.BaseExtNestedEnum#]
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Decl[TypeAlias]/Super: .BaseExtNestedTypealias[#Int#]
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: Keyword[self]/CurrNominal: .self[#ThisDerived1.Type#]; name=self
// FUNC_STATIC_SELF_NO_DOT_1-NEXT: End completions
}

class func staticTest2() {
self.#^FUNC_STATIC_SELF_DOT_1^#
// FUNC_STATIC_SELF_DOT_1: Begin completions
// FUNC_STATIC_SELF_DOT_1-NEXT: Keyword[self]/CurrNominal: self[#ThisDerived1.Type#]; name=self
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[InstanceMethod]/CurrNominal: derivedFunc0({#self: ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[StaticVar]/CurrNominal: derivedStaticVar[#Int#]
// FUNC_STATIC_SELF_DOT_1-NEXT: Decl[StaticMethod]/CurrNominal: derivedStaticFunc0()[#Void#]
Expand Down Expand Up @@ -307,7 +310,8 @@ struct S1 {
init() {}
init(x: Int) {
self.#^STRUCT_CONSTRUCTOR_SELF_DOT_1^#
// STRUCT_CONSTRUCTOR_SELF_DOT_1: Begin completions, 3 items
// STRUCT_CONSTRUCTOR_SELF_DOT_1: Begin completions, 4 items
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Keyword[self]/CurrNominal: self[#S1#]; name=self
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#S1#];
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#x: Int#})[#S1#];
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: f()[#Void#];
Expand Down
5 changes: 3 additions & 2 deletions test/IDE/complete_associated_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func testStruct3(a: StructWithAssociatedTypes) {
}
// STRUCT_TYPE_COUNT: Begin completions, 26 items

// STRUCT_INSTANCE: Begin completions, 14 items
// STRUCT_INSTANCE: Begin completions, 15 items
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonA()[#Int#]
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonB()[#Int#]
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonC()[#Int#]
Expand All @@ -194,6 +194,7 @@ func testStruct3(a: StructWithAssociatedTypes) {
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarBaseC()[#Int#]
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarBaseD()[#Int#]
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceBarD()[#Int#]
// STRUCT_INSTANCE-DAG: Keyword[self]/CurrNominal: self[#StructWithAssociatedTypes#]; name=self
// STRUCT_INSTANCE: End completions

// STRUCT_TYPES: Begin completions
Expand Down Expand Up @@ -266,7 +267,7 @@ struct StructWithBrokenConformance : FooProtocolWithAssociatedTypes {
func testBrokenConformances1() {
StructWithBrokenConformance.#^BROKEN_CONFORMANCE_1^#
}
// BROKEN_CONFORMANCE_1: Begin completions, 34 items
// BROKEN_CONFORMANCE_1: Begin completions, 35 items
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonA[#StructWithBrokenConformance.DefaultedTypeCommonA#]; name=DefaultedTypeCommonA
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: DefaultedTypeCommonB[#StructWithBrokenConformance.DefaultedTypeCommonB#]; name=DefaultedTypeCommonB
// BROKEN_CONFORMANCE_1-DAG: Decl[TypeAlias]/CurrNominal: FooBaseDefaultedTypeB[#StructWithBrokenConformance.FooBaseDefaultedTypeB#]; name=FooBaseDefaultedTypeB
Expand Down
9 changes: 8 additions & 1 deletion test/IDE/complete_at_top_level.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ fooObject#^TYPE_CHECKED_EXPR_1^#
// TYPE_CHECKED_EXPR_1: Begin completions
// TYPE_CHECKED_EXPR_1-NEXT: Decl[InstanceVar]/CurrNominal: .instanceVar[#Int#]{{; name=.+$}}
// TYPE_CHECKED_EXPR_1-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
// TYPE_CHECKED_EXPR_1-NEXT:BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
// TYPE_CHECKED_EXPR_1-NEXT: BuiltinOperator/None: = {#FooStruct#}[#Void#]; name== FooStruct
// TYPE_CHECKED_EXPR_1-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct#]; name=self
// TYPE_CHECKED_EXPR_1-NEXT: End completions

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

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

func resyncParser4() {}

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

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

fooObjectWithErrorInInit.#^TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1^#
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1: Begin completions
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Keyword[self]/CurrNominal: self[#FooStruct#]; name=self
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Decl[InstanceVar]/CurrNominal: instanceVar[#Int#]{{; name=.+$}}
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: Decl[InstanceMethod]/CurrNominal: instanceFunc({#(a): Int#})[#Void#]{{; name=.+$}}
// TYPE_CHECKED_EXPR_WITH_ERROR_IN_INIT_1-NEXT: End completions
Expand All @@ -259,6 +265,7 @@ var topLevelVar2 = FooStruct#^TOP_LEVEL_VAR_INIT_2^#
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[InstanceMethod]/CurrNominal: .instanceFunc({#self: FooStruct#})[#(Int) -> Void#]{{; name=.+$}}
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#FooStruct#]{{; name=.+$}}
// TOP_LEVEL_VAR_INIT_2-NEXT: Decl[Constructor]/CurrNominal: ()[#FooStruct#]{{; name=.+$}}
// TOP_LEVEL_VAR_INIT_2-NEXT: Keyword[self]/CurrNominal: .self[#FooStruct.Type#]; name=self
// TOP_LEVEL_VAR_INIT_2-NEXT: End completions

func resyncParser8() {}
Expand Down
3 changes: 2 additions & 1 deletion test/IDE/complete_call_arg.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ class Bar {
self.collectionView? .#^BOUND_IUO^#x
self.collectionView! .#^FORCED_IUO^#x
}
// MEMBEROF_IUO: Begin completions, 1 items
// MEMBEROF_IUO: Begin completions, 2 items
// MEMBEROF_IUO: Keyword[self]/CurrNominal: self[#Foo#]; name=self
// MEMBEROF_IUO: Decl[InstanceVar]/CurrNominal: x[#Int#]; name=x
// MEMBEROF_IUO: End completions
}
22 changes: 15 additions & 7 deletions test/IDE/complete_constructor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ struct ImplicitConstructors1 {

func testImplicitConstructors1() {
ImplicitConstructors1#^IMPLICIT_CONSTRUCTORS_1^#
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 1 items
// IMPLICIT_CONSTRUCTORS_1: Begin completions, 2 items
// IMPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors1#]{{; name=.+$}}
// IMPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors1.Type#]; name=self
// IMPLICIT_CONSTRUCTORS_1: End completions
}
func testImplicitConstructors1P() {
Expand All @@ -58,9 +59,10 @@ struct ImplicitConstructors2 {

func testImplicitConstructors2() {
ImplicitConstructors2#^IMPLICIT_CONSTRUCTORS_2^#
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 2 items
// IMPLICIT_CONSTRUCTORS_2: Begin completions, 3 items
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#instanceVar: Int#})[#ImplicitConstructors2#]{{; name=.+$}}
// IMPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ImplicitConstructors2#]{{; name=.+$}}
// IMPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ImplicitConstructors2.Type#]; name=self
// IMPLICIT_CONSTRUCTORS_2: End completions
}
func testImplicitConstructors2P() {
Expand All @@ -78,10 +80,11 @@ struct ExplicitConstructors1 {

func testExplicitConstructors1() {
ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_1^#
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 3 items
// EXPLICIT_CONSTRUCTORS_1: Begin completions, 4 items
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
// EXPLICIT_CONSTRUCTORS_1: End completions
}
func testExplicitConstructors1P() {
Expand All @@ -94,10 +97,11 @@ func testExplicitConstructors1P() {

ExplicitConstructors1#^EXPLICIT_CONSTRUCTORS_2^#

// EXPLICIT_CONSTRUCTORS_2: Begin completions, 3 items
// EXPLICIT_CONSTRUCTORS_2: Begin completions, 4 items
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructors1#]
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructors1#]
// EXPLICIT_CONSTRUCTORS_2-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#}, {#b: Float#})[#ExplicitConstructors1#]
// EXPLICIT_CONSTRUCTORS_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructors1.Type#]; name=self
// EXPLICIT_CONSTRUCTORS_2: End completions

ExplicitConstructors1(#^EXPLICIT_CONSTRUCTORS_2P^#
Expand Down Expand Up @@ -130,9 +134,10 @@ struct ExplicitConstructorsSelector1 {

func testExplicitConstructorsSelector1() {
ExplicitConstructorsSelector1#^EXPLICIT_CONSTRUCTORS_SELECTOR_1^#
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 2 items
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: Begin completions, 3 items
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#andFloat: Float#})[#ExplicitConstructorsSelector1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector1.Type#]; name=self
// EXPLICIT_CONSTRUCTORS_SELECTOR_1: End completions
}

Expand All @@ -145,11 +150,12 @@ struct ExplicitConstructorsSelector2 {

func testExplicitConstructorsSelector2() {
ExplicitConstructorsSelector2#^EXPLICIT_CONSTRUCTORS_SELECTOR_2^#
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 4 items
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: Begin completions, 5 items
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#noArgs: ()#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#Int#}, {#withFloat: Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Decl[Constructor]/CurrNominal: ({#int: Int#}, {#Float#})[#ExplicitConstructorsSelector2#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_SELECTOR_2-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsSelector2.Type#]; name=self
// EXPLICIT_CONSTRUCTORS_SELECTOR_2: End completions
}

Expand All @@ -174,16 +180,18 @@ class ExplicitConstructorsDerived2 : ExplicitConstructorsBase1 {
func testExplicitConstructorsBaseDerived1() {
ExplicitConstructorsDerived1#^EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1^#
}
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 2 items
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: Begin completions, 3 items
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ()[#ExplicitConstructorsDerived1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Decl[Constructor]/CurrNominal: ({#a: Int#})[#ExplicitConstructorsDerived1#]{{; name=.+$}}
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1-DAG: Keyword[self]/CurrNominal: .self[#ExplicitConstructorsDerived1.Type#]; name=self
// EXPLICIT_CONSTRUCTORS_BASE_DERIVED_1: End completions

func testGetInitFromMetatype1() {
ExplicitConstructorsBase1.#^INIT_FROM_METATYPE1^#
}

// INIT_FROM_METATYPE1: Begin completions
// INIT_FROM_METATYPE1-NEXT: Keyword[self]/CurrNominal: self[#ExplicitConstructorsBase1.Type#]; name=self
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init()[#ExplicitConstructorsBase1#]{{; name=.+$}}
// INIT_FROM_METATYPE1-NEXT: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ExplicitConstructorsBase1#]{{; name=.+$}}
// INIT_FROM_METATYPE1-NEXT: End completions
Expand Down
6 changes: 4 additions & 2 deletions test/IDE/complete_crashes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ protocol BadMembers2 {
func badMembers2(_ a: BadMembers2) {
a#^BAD_MEMBERS_2^#
}
// BAD_MEMBERS_2: Begin completions, 2 items
// BAD_MEMBERS_2: Begin completions, 3 items
// BAD_MEMBERS_2-NEXT: Decl[InstanceVar]/CurrNominal: .prop[#Int#]{{; name=.+$}}
// BAD_MEMBERS_2-NEXT: Decl[Subscript]/CurrNominal: [{#Int#}][#Double#]{{; name=.+$}}
// BAD_MEMBERS_2-NEXT: Keyword[self]/CurrNominal: .self[#BadMembers2#]; name=self
// BAD_MEMBERS_2-NEXT: End completions

func globalFunc() {}
Expand Down Expand Up @@ -220,10 +221,11 @@ protocol Bar_38149042 {
func foo_38149042(bar: Bar_38149042) {
_ = bar.foo? #^RDAR_38149042^# .x
}
// RDAR_38149042: Begin completions, 3 items
// RDAR_38149042: Begin completions, 4 items
// RDAR_38149042-DAG: Decl[InstanceVar]/CurrNominal: .x[#Int#]; name=x
// RDAR_38149042-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']=== {#AnyObject?#}[#Bool#]; name==== AnyObject?
// RDAR_38149042-DAG: Decl[InfixOperatorFunction]/OtherModule[Swift]: [' ']!== {#AnyObject?#}[#Bool#]; name=!== AnyObject?
// RDAR_38149042-DAG: Keyword[self]/CurrNominal: .self[#Baz_38149042#]; name=self
// RDAR_38149042: End completions

// rdar://problem/38272904
Expand Down
Loading