From d0f02be81f92dbc1578e478f5ac80de6b6cf863c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 16:36:55 -0500 Subject: [PATCH 01/14] Sema: Remove hack introduced by 31245556 It looks like Type::subst() was subsequently fixed for GenericFunctionTypes in 06d16795 so we can remove this hack. --- lib/AST/LookupVisibleDecls.cpp | 17 ++--------------- test/IDE/complete_from_stdlib.swift | 2 +- test/IDE/complete_value_expr.swift | 5 ++++- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 8acde2c4fa488..c1e37cc6683df 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -768,17 +768,6 @@ template <> struct DenseMapInfo { namespace { -/// Hack to guess at whether substituting into the type of a declaration will -/// be okay. -/// FIXME: This is awful. We should either have Type::subst() work for -/// GenericFunctionType, or we should kill it outright. -static bool shouldSubstIntoDeclType(Type type) { - auto genericFnType = type->getAs(); - if (!genericFnType) return true; - - return false; -} - class OverrideFilteringConsumer : public VisibleDeclConsumer { public: std::set AllFoundDecls; @@ -870,8 +859,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { auto FoundSignature = VD->getOverloadSignature(); auto FoundSignatureType = VD->getOverloadSignatureType(); - if (FoundSignatureType && shouldSubst && - shouldSubstIntoDeclType(FoundSignatureType)) { + if (FoundSignatureType && shouldSubst) { auto subs = BaseTy->getMemberSubstitutionMap(M, VD); if (auto CT = FoundSignatureType.subst(subs)) FoundSignatureType = CT->getCanonicalType(); @@ -888,8 +876,7 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { auto OtherSignature = OtherVD->getOverloadSignature(); auto OtherSignatureType = OtherVD->getOverloadSignatureType(); - if (OtherSignatureType && shouldSubst && - shouldSubstIntoDeclType(OtherSignatureType)) { + if (OtherSignatureType && shouldSubst) { auto subs = BaseTy->getMemberSubstitutionMap(M, OtherVD); if (auto CT = OtherSignatureType.subst(subs)) OtherSignatureType = CT->getCanonicalType(); diff --git a/test/IDE/complete_from_stdlib.swift b/test/IDE/complete_from_stdlib.swift index b7aad664a1916..0c034b42e5741 100644 --- a/test/IDE/complete_from_stdlib.swift +++ b/test/IDE/complete_from_stdlib.swift @@ -148,7 +148,7 @@ func testArchetypeReplacement2(_ a: [BAR]) { // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/CurrNominal: append({#(newElement): Equatable#})[#Void#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/CurrNominal: insert({#(newElement): Equatable#}, {#at: Int#})[#Void#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropFirst()[#ArraySlice#]{{; name=.+}} -// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropLast()[#ArraySlice#]{{; name=.+}} +// PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: dropLast()[#[Equatable]#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: enumerated()[#EnumeratedSequence<[Equatable]>#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: min({#by: (Equatable, Equatable) throws -> Bool##(Equatable, Equatable) throws -> Bool#})[' rethrows'][#Equatable?#]{{; name=.+}} // PRIVATE_NOMINAL_MEMBERS_6-DAG: Decl[InstanceMethod]/Super: max({#by: (Equatable, Equatable) throws -> Bool##(Equatable, Equatable) throws -> Bool#})[' rethrows'][#Equatable?#]{{; name=.+}} diff --git a/test/IDE/complete_value_expr.swift b/test/IDE/complete_value_expr.swift index 5bf21e2df4d59..078c9f50f3163 100644 --- a/test/IDE/complete_value_expr.swift +++ b/test/IDE/complete_value_expr.swift @@ -1850,10 +1850,13 @@ struct dedupS : dedupP { func testDeDuped(_ x: dedupS) { x#^PROTOCOL_EXT_DEDUP_1^# // FIXME: Should produce 3 items (?) -// PROTOCOL_EXT_DEDUP_1: Begin completions, 7 items + +// PROTOCOL_EXT_DEDUP_1: Begin completions, 6 items // PROTOCOL_EXT_DEDUP_1: Decl[InstanceMethod]/CurrNominal: .foo()[#Int#]; name=foo() // PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/CurrNominal: .bar[#Int#]; name=bar // PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/CurrNominal: [{#Int#}][#Int#]; name=[Int] +// PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/Super: .bar[#Int#]; name=bar +// PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/Super: [{#Self.T#}][#Self.T#]; name=[Self.T] // PROTOCOL_EXT_DEDUP_1: Keyword[self]/CurrNominal: .self[#dedupS#]; name=self // PROTOCOL_EXT_DEDUP_1: End completions } From 9e70c57f3c2151ae454fadf787d47a6bd40f367d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 18:26:47 -0500 Subject: [PATCH 02/14] AST: Change TypeBase::addCurriedSelfType() to use the self type not declared type In a protocol, the overload signature type of a property is (Self) -> (), not (Proto) -> (). --- lib/AST/Type.cpp | 2 +- test/IDE/complete_value_expr.swift | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 9406e4235abe0..d5c5f3bc43ba4 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -439,7 +439,7 @@ Type TypeBase::addCurriedSelfType(const DeclContext *dc) { genericFn->getExtInfo()); } - auto selfTy = dc->getDeclaredInterfaceType(); + auto selfTy = dc->getSelfInterfaceType(); auto selfParam = AnyFunctionType::Param(selfTy); if (sig) return GenericFunctionType::get(sig, {selfParam}, type); diff --git a/test/IDE/complete_value_expr.swift b/test/IDE/complete_value_expr.swift index 078c9f50f3163..56a527693c349 100644 --- a/test/IDE/complete_value_expr.swift +++ b/test/IDE/complete_value_expr.swift @@ -1851,12 +1851,11 @@ func testDeDuped(_ x: dedupS) { x#^PROTOCOL_EXT_DEDUP_1^# // FIXME: Should produce 3 items (?) -// PROTOCOL_EXT_DEDUP_1: Begin completions, 6 items +// PROTOCOL_EXT_DEDUP_1: Begin completions, 5 items // PROTOCOL_EXT_DEDUP_1: Decl[InstanceMethod]/CurrNominal: .foo()[#Int#]; name=foo() // PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/CurrNominal: .bar[#Int#]; name=bar // PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/CurrNominal: [{#Int#}][#Int#]; name=[Int] // PROTOCOL_EXT_DEDUP_1: Decl[InstanceVar]/Super: .bar[#Int#]; name=bar -// PROTOCOL_EXT_DEDUP_1: Decl[Subscript]/Super: [{#Self.T#}][#Self.T#]; name=[Self.T] // PROTOCOL_EXT_DEDUP_1: Keyword[self]/CurrNominal: .self[#dedupS#]; name=self // PROTOCOL_EXT_DEDUP_1: End completions } From e55ae8b2850b1515dbc9613242c27bce1fcb36e7 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 18:32:10 -0500 Subject: [PATCH 03/14] AST: Remove obsolete comment --- lib/AST/Type.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index d5c5f3bc43ba4..414f006394acb 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -860,7 +860,6 @@ Type TypeBase::getMetatypeInstanceType() { if (auto metaTy = getAs()) return metaTy->getInstanceType(); - // For mutable value type methods, we need to dig through inout types. return this; } From 8956804d79e509359b7f679e3bc05872d206914b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 18:32:22 -0500 Subject: [PATCH 04/14] LookupVisibleDecls: Use TypeBase::getMetatypeInstanceType() --- lib/AST/LookupVisibleDecls.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index c1e37cc6683df..18e8efa587d99 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -776,16 +776,12 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { Type BaseTy; const DeclContext *DC; LazyResolver *TypeResolver; - bool IsTypeLookup = false; OverrideFilteringConsumer(Type BaseTy, const DeclContext *DC, LazyResolver *resolver) - : BaseTy(BaseTy), DC(DC), TypeResolver(resolver) { + : BaseTy(BaseTy->getMetatypeInstanceType()), + DC(DC), TypeResolver(resolver) { assert(!BaseTy->hasLValueType()); - if (auto *MetaTy = BaseTy->getAs()) { - BaseTy = MetaTy->getInstanceType(); - IsTypeLookup = true; - } assert(DC && BaseTy); } From ae3395cea7926ee81dbb2d98fae888d0239a037b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 18:32:39 -0500 Subject: [PATCH 05/14] LookupVisibleDecls: Also substitute when the base type is an archetype --- lib/AST/LookupVisibleDecls.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 18e8efa587d99..6a3fbd7ffc7b1 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -842,7 +842,8 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { // don't substitute either. bool shouldSubst = (!BaseTy->isAnyObject() && !BaseTy->hasTypeVariable() && - BaseTy->getNominalOrBoundGenericNominal() && + (BaseTy->getNominalOrBoundGenericNominal() || + BaseTy->is()) && VD->getDeclContext()->isTypeContext()); ModuleDecl *M = DC->getParentModule(); From bd88ee0a326cd4f3cbc4bfd10f44a1f18bc6e25a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 19:51:11 -0500 Subject: [PATCH 06/14] LookupVisibleDecls: Don't use getReasonForSuper() for members of protocols and superclass constraints on an archetype Semantically, these are not superclass/refined-protocol members. If I have a generic parameter , then when looking at a value of type T, members of P and Q are at the same "level" as if I had a value of type (P & Q). --- lib/AST/LookupVisibleDecls.cpp | 5 +- test/IDE/complete_members_optional.swift | 10 +- test/IDE/complete_operators.swift | 4 +- test/IDE/complete_type.swift | 8 +- test/IDE/complete_type_subscript.swift | 4 +- test/IDE/complete_value_expr.swift | 144 ++++++++++-------- test/IDE/complete_where_clause.swift | 11 +- .../complete_optionalmethod.swift.response | 2 +- 8 files changed, 99 insertions(+), 89 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 6a3fbd7ffc7b1..a15f2c8138dcd 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -642,12 +642,11 @@ static void lookupVisibleMemberDeclsImpl( for (auto Proto : Archetype->getConformsTo()) lookupVisibleProtocolMemberDecls( BaseTy, Proto->getDeclaredType(), Consumer, CurrDC, LS, - getReasonForSuper(Reason), TypeResolver, GSB, Visited); + Reason, TypeResolver, GSB, Visited); if (auto superclass = Archetype->getSuperclass()) lookupVisibleMemberDeclsImpl(superclass, Consumer, CurrDC, LS, - getReasonForSuper(Reason), TypeResolver, - GSB, Visited); + Reason, TypeResolver, GSB, Visited); return; } diff --git a/test/IDE/complete_members_optional.swift b/test/IDE/complete_members_optional.swift index 912cfa38b3291..5aa726a30c80e 100644 --- a/test/IDE/complete_members_optional.swift +++ b/test/IDE/complete_members_optional.swift @@ -29,8 +29,8 @@ func optionalMembers1(_ a: HasOptionalMembers1) { a.#^OPTIONAL_MEMBERS_1^# } // OPTIONAL_MEMBERS_1: Begin completions, 3 items -// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?()[#Int#]{{; name=.+$}} -// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceVar]/CurrNominal: optionalInstanceProperty[#Int?#]{{; name=.+$}} +// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?()[#Int#]{{; name=.+$}} +// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceVar]/CurrNominal: optionalInstanceProperty[#Int?#]{{; name=.+$}} // OPTIONAL_MEMBERS_1-DAG: Keyword[self]/CurrNominal: self[#HasOptionalMembers1#]; name=self // OPTIONAL_MEMBERS_1: End completions @@ -38,8 +38,8 @@ func optionalMembers2(_ a: T) { T.#^OPTIONAL_MEMBERS_2^# } // OPTIONAL_MEMBERS_2: Begin completions, 4 items -// OPTIONAL_MEMBERS_2-DAG: Decl[InstanceMethod]/Super: optionalInstanceFunc?({#self: HasOptionalMembers1#})[#() -> Int#]{{; name=.+$}} -// OPTIONAL_MEMBERS_2-DAG: Decl[StaticMethod]/Super: optionalClassFunc?()[#Int#]{{; name=.+$}} -// OPTIONAL_MEMBERS_2-DAG: Decl[StaticVar]/Super: optionalClassProperty[#Int?#]{{; name=.+$}} +// OPTIONAL_MEMBERS_2-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?({#self: HasOptionalMembers1#})[#() -> Int#]{{; name=.+$}} +// OPTIONAL_MEMBERS_2-DAG: Decl[StaticMethod]/CurrNominal: optionalClassFunc?()[#Int#]{{; name=.+$}} +// OPTIONAL_MEMBERS_2-DAG: Decl[StaticVar]/CurrNominal: optionalClassProperty[#Int?#]{{; name=.+$}} // OPTIONAL_MEMBERS_2-DAG: Keyword[self]/CurrNominal: self[#T.Type#]; name=self // OPTIONAL_MEMBERS_2: End completions diff --git a/test/IDE/complete_operators.swift b/test/IDE/complete_operators.swift index 5b53fb8fdf34f..c6fa650d52aa1 100644 --- a/test/IDE/complete_operators.swift +++ b/test/IDE/complete_operators.swift @@ -279,8 +279,8 @@ func testInfix15() { T#^INFIX_15^# } // INFIX_15: Begin completions, 3 items -// INFIX_15-NEXT: Decl[AssociatedType]/Super: .T; name=T -// INFIX_15-NEXT: Decl[InstanceMethod]/Super: .foo({#self: P#})[#() -> S2#]; name=foo(P) +// INFIX_15-NEXT: Decl[AssociatedType]/CurrNominal: .T; name=T +// INFIX_15-NEXT: Decl[InstanceMethod]/CurrNominal: .foo({#self: P#})[#() -> S2#]; name=foo(P) // INFIX_15-NEXT: Keyword[self]/CurrNominal: .self[#T.Type#]; name=self // INFIX_15: End completions diff --git a/test/IDE/complete_type.swift b/test/IDE/complete_type.swift index ce22a39c0d37f..d6960fd528bff 100644 --- a/test/IDE/complete_type.swift +++ b/test/IDE/complete_type.swift @@ -456,7 +456,7 @@ typealias FooTypealias = Int //===--- // TYPE_IN_PROTOCOL: Begin completions -// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/Super: Self[#Self#]{{; name=.+$}} +// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/CurrNominal: Self[#Self#]{{; name=.+$}} // TYPE_IN_PROTOCOL: End completions protocol TestSelf1 { @@ -1013,7 +1013,7 @@ func testTypeIdentifierGeneric1< >(a: GenericFoo.#^TYPE_IDENTIFIER_GENERIC_1^# // TYPE_IDENTIFIER_GENERIC_1: Begin completions -// TYPE_IDENTIFIER_GENERIC_1-NEXT: Decl[AssociatedType]/Super: FooTypeAlias1{{; name=.+$}} +// TYPE_IDENTIFIER_GENERIC_1-NEXT: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}} // TYPE_IDENTIFIER_GENERIC_1-NEXT: Keyword/None: Type[#GenericFoo.Type#] // TYPE_IDENTIFIER_GENERIC_1-NEXT: End completions @@ -1022,8 +1022,8 @@ func testTypeIdentifierGeneric2< >(a: GenericFoo.#^TYPE_IDENTIFIER_GENERIC_2^# // TYPE_IDENTIFIER_GENERIC_2: Begin completions -// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/Super: BarTypeAlias1{{; name=.+$}} -// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/Super: FooTypeAlias1{{; name=.+$}} +// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/CurrNominal: BarTypeAlias1{{; name=.+$}} +// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}} // TYPE_IDENTIFIER_GENERIC_2-NEXT: Keyword/None: Type[#GenericFoo.Type#] // TYPE_IDENTIFIER_GENERIC_2-NEXT: End completions diff --git a/test/IDE/complete_type_subscript.swift b/test/IDE/complete_type_subscript.swift index cfbf9bb8b6050..707443d3ba385 100644 --- a/test/IDE/complete_type_subscript.swift +++ b/test/IDE/complete_type_subscript.swift @@ -100,7 +100,7 @@ extension G6 { subscript(b x: T.#^GEN_EXT_PARAM_6^#) -> Int { return 0 } subscript(b x: Int) -> T.#^GEN_EXT_RETURN_6^# { return 0 } } -// GEN_PARAM_6-DAG: Decl[AssociatedType]/Super: Assoc; +// GEN_PARAM_6-DAG: Decl[AssociatedType]/CurrNominal: Assoc; // GEN_PARAM_6-DAG: Keyword/None: Type[#T.Type#]; // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENPROTO_PARAM_1 | %FileCheck %s -check-prefix=GENPROTO_1 @@ -116,5 +116,5 @@ extension GP1 { subscript(b x: I.#^GENPROTO_EXT_PARAM_1^#) -> Int { return 1 } subscript(b x: Int) -> I.#^GENPROTO_EXT_RETURN_1^# { return 1 } } -// GENPROTO_1-DAG: Decl[AssociatedType]/Super: Assoc; +// GENPROTO_1-DAG: Decl[AssociatedType]/CurrNominal: Assoc; // GENPROTO_1-DAG: Keyword/None: Type[#Self.I.Type#]; diff --git a/test/IDE/complete_value_expr.swift b/test/IDE/complete_value_expr.swift index 56a527693c349..b6ae225da9977 100644 --- a/test/IDE/complete_value_expr.swift +++ b/test/IDE/complete_value_expr.swift @@ -122,9 +122,9 @@ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ4 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ5 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ6 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE1 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE2 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE -// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE3 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE1 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE1 +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE2 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE2 +// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_TYPE3 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_TYPE3 // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_NODOT1 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_NODOT // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_NODOT2 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_NODOT // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NODUP_RESTATED_REQ_NODOT3 | %FileCheck %s -check-prefix=CHECK_NODUP_RESTATED_REQ_NODOT @@ -1006,10 +1006,10 @@ func testResolveFuncParam3(_ foo: Foo) { foo.#^RESOLVE_FUNC_PARAM_3^# // RESOLVE_FUNC_PARAM_3: Begin completions // RESOLVE_FUNC_PARAM_3-NEXT: Keyword[self]/CurrNominal: self[#Foo#]; name=self -// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_3-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_3-NEXT: End completions } @@ -1017,13 +1017,13 @@ func testResolveFuncParam4(_ fooBar: FooBar) fooBar.#^RESOLVE_FUNC_PARAM_4^# // RESOLVE_FUNC_PARAM_4: Begin completions // RESOLVE_FUNC_PARAM_4-NEXT: Keyword[self]/CurrNominal: self[#FooBar#]; name=self -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/Super: barInstanceVar[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/Super: barInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/Super: barInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/CurrNominal: barInstanceVar[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/CurrNominal: barInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/CurrNominal: barInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_4-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_4-NEXT: End completions } @@ -1031,15 +1031,15 @@ func testResolveFuncParam5(_ a: FooE a.#^RESOLVE_FUNC_PARAM_5^# // RESOLVE_FUNC_PARAM_5: Begin completions // RESOLVE_FUNC_PARAM_5-NEXT: Keyword[self]/CurrNominal: self[#FooExBarEx#]; name=self -// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: barInstanceVar[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: barInstanceVar[#Int#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: barInstanceFunc0()[#Double#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: barInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: barExInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/CurrNominal: barExInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/Super: fooExInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_5-NEXT: Decl[InstanceMethod]/CurrNominal: fooExInstanceFunc0()[#Double#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_5-NEXT: End completions } @@ -1047,13 +1047,13 @@ func testResolveFuncParam6(_ foo: Foo) { foo.#^RESOLVE_FUNC_PARAM_6^# // RESOLVE_FUNC_PARAM_6: Begin completions // RESOLVE_FUNC_PARAM_6-NEXT: Keyword[self]/CurrNominal: self[#Foo#]; name=self -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/Super: fooClassInstanceVar[#Int#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/Super: fooClassInstanceFunc0()[#Void#]{{; name=.+$}} -// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/Super: fooClassInstanceFunc1({#(a): Int#})[#Void#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceVar]/CurrNominal: fooClassInstanceVar[#Int#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/CurrNominal: fooClassInstanceFunc0()[#Void#]{{; name=.+$}} +// RESOLVE_FUNC_PARAM_6-NEXT: Decl[InstanceMethod]/CurrNominal: fooClassInstanceFunc1({#(a): Int#})[#Void#]{{; name=.+$}} // RESOLVE_FUNC_PARAM_6-NEXT: End completions } @@ -1068,10 +1068,10 @@ class TestResolveConstructorParam2 { foo.#^RESOLVE_CONSTRUCTOR_PARAM_2^# // RESOLVE_CONSTRUCTOR_PARAM_2: Begin completions // RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Keyword[self]/CurrNominal: self[#Foo#]; name=self -// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} // RESOLVE_CONSTRUCTOR_PARAM_2-NEXT: End completions } } @@ -1081,10 +1081,10 @@ class TestResolveConstructorParam3 { foo.#^RESOLVE_CONSTRUCTOR_PARAM_3^# // RESOLVE_CONSTRUCTOR_PARAM_3: Begin completions // RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Keyword[self]/CurrNominal: self[#Foo#]; name=self -// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceVar]/Super: fooInstanceVar1[#Int#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceVar]/Super: fooInstanceVar2[#Int#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc0()[#Double#]{{; name=.+$}} -// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceMethod]/Super: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar1[#Int#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceVar]/CurrNominal: fooInstanceVar2[#Int#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc0()[#Double#]{{; name=.+$}} +// RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: Decl[InstanceMethod]/CurrNominal: fooInstanceFunc1({#(a): Int#})[#Double#]{{; name=.+$}} // RESOLVE_CONSTRUCTOR_PARAM_3-NEXT: End completions } } @@ -1516,29 +1516,29 @@ func testGenericConforming1(x: T) { x.#^PROTOCOL_EXT_GENERICP1^# } // PROTOCOL_EXT_GENERICP1: Begin completions -// PROTOCOL_EXT_GENERICP1-DAG: Decl[InstanceMethod]/Super: reqP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP1-DAG: Decl[InstanceMethod]/Super: extP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP1-DAG: Decl[InstanceMethod]/CurrNominal: reqP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP1-DAG: Decl[InstanceMethod]/CurrNominal: extP1()[#Void#]{{; name=.+$}} // PROTOCOL_EXT_GENERICP1: End completions func testGenericConforming2(x: T) { x.#^PROTOCOL_EXT_GENERICP2^# } // PROTOCOL_EXT_GENERICP2: Begin completions -// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: reqP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: reqP2()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: extP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: extP2()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: reqP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/CurrNominal: reqP2()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/Super: extP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP2-DAG: Decl[InstanceMethod]/CurrNominal: extP2()[#Void#]{{; name=.+$}} // PROTOCOL_EXT_GENERICP2: End completions func testGenericConforming3(x: T) { x.#^PROTOCOL_EXT_GENERICP3^# } // PROTOCOL_EXT_GENERICP3: Begin completions -// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: reqP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: reqP2()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: extP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: extP2()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: extP3()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: reqP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: reqP2()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: extP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/Super: extP2()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_GENERICP3-DAG: Decl[InstanceMethod]/CurrNominal: extP3()[#Void#]{{; name=.+$}} // PROTOCOL_EXT_GENERICP3: End completions protocol NoDupReq1 { @@ -1647,14 +1647,26 @@ func checkOverrideInclusion2(_ arg: Override3) { // CHECK_NODUP_RESTATED_REQ_NODOT-NOT: Decl[InstanceVar]/{{Super|CurrNominal}}: .doo[#Int#]; name=doo // CHECK_NODUP_RESTATED_REQ_NODOT: End completions -// CHECK_NODUP_RESTATED_REQ_TYPE: Begin completions -// CHECK_NODUP_RESTATED_REQ_TYPE-DAG: Decl[InstanceMethod]/Super: foo({#self: [[ARG:.+]]#})[#() -> Void#]; name=foo([[ARG]]) -// CHECK_NODUP_RESTATED_REQ_TYPE-DAG: Decl[InstanceMethod]/Super: roo({#self: [[ARG]]#})[#(arg1: Int) -> Void#]; name=roo([[ARG]]) -// CHECK_NODUP_RESTATED_REQ_TYPE-DAG: Decl[AssociatedType]/Super: E; name=E -// CHECK_NODUP_RESTATED_REQ_TYPE-DAG: Decl[InstanceMethod]/Super: roo({#self: [[ARG]]#})[#(arg2: Int) -> Void#]; name=roo([[ARG]]) -// CHECK_NODUP_RESTATED_REQ_TYPE-NOT: Decl[InstanceMethod]/Super: foo({#self: [[ARG:.+]]#})[#() -> Void#]; name=foo([[ARG]]) -// CHECK_NODUP_RESTATED_REQ_TYPE-NOT: Decl[AssociatedType]/Super: E; name=E -// CHECK_NODUP_RESTATED_REQ_TYPE: End completions +// CHECK_NODUP_RESTATED_REQ_TYPE1: Begin completions, 5 items +// CHECK_NODUP_RESTATED_REQ_TYPE1: Decl[InstanceMethod]/Super: foo({#self: NoDupReq6#})[#() -> Void#]; name=foo(NoDupReq6) +// CHECK_NODUP_RESTATED_REQ_TYPE1: Decl[InstanceMethod]/Super: roo({#self: NoDupReq6#})[#(arg1: Int) -> Void#]; name=roo(NoDupReq6 +// CHECK_NODUP_RESTATED_REQ_TYPE1: Decl[AssociatedType]/Super: E; name=E +// CHECK_NODUP_RESTATED_REQ_TYPE1: Decl[InstanceMethod]/CurrNominal: roo({#self: NoDupReq6#})[#(arg2: Int) -> Void#]; name=roo(NoDupReq6) +// CHECK_NODUP_RESTATED_REQ_TYPE1: End completions + +// CHECK_NODUP_RESTATED_REQ_TYPE2: Begin completions, 5 items +// CHECK_NODUP_RESTATED_REQ_TYPE2: Decl[InstanceMethod]/CurrNominal: foo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#() -> Void#]; name=foo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE2: Decl[InstanceMethod]/CurrNominal: roo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#(arg1: Int) -> Void#]; name=roo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE2: Decl[AssociatedType]/CurrNominal: E; name=E +// CHECK_NODUP_RESTATED_REQ_TYPE2: Decl[InstanceMethod]/CurrNominal: roo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#(arg2: Int) -> Void#]; name=roo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE2: End completions + +// CHECK_NODUP_RESTATED_REQ_TYPE3: Begin completions, 5 items +// CHECK_NODUP_RESTATED_REQ_TYPE3: Decl[InstanceMethod]/CurrNominal: foo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#() -> Void#]; name=foo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE3: Decl[InstanceMethod]/CurrNominal: roo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#(arg1: Int) -> Void#]; name=roo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE3: Decl[AssociatedType]/CurrNominal: E; name=E +// CHECK_NODUP_RESTATED_REQ_TYPE3: Decl[InstanceMethod]/CurrNominal: roo({#self: NoDupReq1 & NoDupReq2 & NoDupReq3#})[#(arg2: Int) -> Void#]; name=roo(NoDupReq1 & NoDupReq2 & NoDupReq3) +// CHECK_NODUP_RESTATED_REQ_TYPE3: End completions // CHECK_PROT_OVERRIDES: Decl[InstanceMethod]/{{Super|CurrNominal}}: foo({#(arg): NoDupReq1#})[#Void#]; name=foo(arg: NoDupReq1) // CHECK_PROT_OVERRIDES: Decl[InstanceMethod]/{{Super|CurrNominal}}: foo({#(arg): NoDupReq2#})[#Void#]; name=foo(arg: NoDupReq2) @@ -1715,8 +1727,8 @@ extension Concrete1 { } // PROTOCOL_EXT_P4_P1: Begin completions // PROTOCOL_EXT_P4_P1-NOT: extP4OnlyMe() -// PROTOCOL_EXT_P4_P1-DAG: Decl[InstanceMethod]/Super: extP4WhenP1()[#Void#]{{; name=.+$}} -// PROTOCOL_EXT_P4_P1-DAG: Decl[InstanceVar]/Super: x[#Int#]{{; name=.+$}} +// PROTOCOL_EXT_P4_P1-DAG: Decl[InstanceMethod]/{{Super|CurrNominal}}: extP4WhenP1()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_P4_P1-DAG: Decl[InstanceVar]/{{Super|CurrNominal}}: x[#Int#]{{; name=.+$}} // PROTOCOL_EXT_P4_P1-NOT: extP4OnlyMe() // PROTOCOL_EXT_P4_P1: End completions @@ -1746,13 +1758,13 @@ extension Concrete2 { // PROTOCOL_EXT_P4_ONLYME: Begin completions // PROTOCOL_EXT_P4_ONLYME-NOT: extP4WhenP1() // PROTOCOL_EXT_P4_ONLYME-NOT: x[#Int#] -// PROTOCOL_EXT_P4_ONLYME-DAG: Decl[InstanceMethod]/Super: extP4OnlyMe()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_P4_ONLYME-DAG: Decl[InstanceMethod]/{{Super|CurrNominal}}: extP4OnlyMe()[#Void#]{{; name=.+$}} // PROTOCOL_EXT_P4_ONLYME-NOT: extP4WhenP1() // PROTOCOL_EXT_P4_ONLYME-NOT: x[#Int#] // PROTOCOL_EXT_P4_ONLYME: End completions // PROTOCOL_EXT_P4_ONLYME_SUB: Begin completions -// PROTOCOL_EXT_P4_ONLYME_SUB: Decl[Subscript]/Super: [{#Int#}][#Int#]{{; name=.+$}} +// PROTOCOL_EXT_P4_ONLYME_SUB: Decl[Subscript]/{{Super|CurrNominal}}: [{#Int#}][#Int#]{{; name=.+$}} // PROTOCOL_EXT_P4_ONLYME_SUB: End completions func testTypealias1() { @@ -1770,7 +1782,7 @@ func testProtExtInit1() { } // PROTOCOL_EXT_INIT_1: Begin completions -// PROTOCOL_EXT_INIT_1: Decl[Constructor]/Super: ['(']{#x: Int#}[')'][#Concrete1#]{{; name=.+$}} +// PROTOCOL_EXT_INIT_1: Decl[Constructor]/{{Super|CurrNominal}}: ['(']{#x: Int#}[')'][#Concrete1#]{{; name=.+$}} // PROTOCOL_EXT_INIT_1: End completions func testProtExtInit2() { @@ -1779,9 +1791,9 @@ func testProtExtInit2() { S#^PROTOCOL_EXT_INIT_4^# } -// PROTOCOL_EXT_INIT_2: Decl[Constructor]/Super: ['(']{#x: Int#}[')'][#P4#]{{; name=.+$}} -// PROTOCOL_EXT_INIT_3: Decl[Constructor]/Super: init({#x: Int#})[#P4#]{{; name=.+$}} -// PROTOCOL_EXT_INIT_4: Decl[Constructor]/Super: ({#x: Int#})[#P4#]{{; name=.+$}} +// PROTOCOL_EXT_INIT_2: Decl[Constructor]/CurrNominal: ['(']{#x: Int#}[')'][#P4#]{{; name=.+$}} +// PROTOCOL_EXT_INIT_3: Decl[Constructor]/CurrNominal: init({#x: Int#})[#P4#]{{; name=.+$}} +// PROTOCOL_EXT_INIT_4: Decl[Constructor]/CurrNominal: ({#x: Int#})[#P4#]{{; name=.+$}} extension P4 where Self.T == OnlyMe { final func test1() { @@ -1793,7 +1805,7 @@ extension P4 where Self.T == OnlyMe { } // PROTOCOL_EXT_P4_DOT: Begin completions // PROTOCOL_EXT_P4_DOT-NOT: extP4WhenP1() -// PROTOCOL_EXT_P4_DOT-DAG: Decl[InstanceMethod]/Super: extP4OnlyMe()[#Void#]{{; name=.+$}} +// PROTOCOL_EXT_P4_DOT-DAG: Decl[InstanceMethod]/{{Super|CurrNominal}}: extP4OnlyMe()[#Void#]{{; name=.+$}} // PROTOCOL_EXT_P4_DOT-NOT: extP4WhenP1() // PROTOCOL_EXT_P4_DOT: End completions @@ -1871,10 +1883,10 @@ func testDeDuped2(_ x: dedupP) { func testDeDuped3(_ x: T) { x#^PROTOCOL_EXT_DEDUP_3^# // PROTOCOL_EXT_DEDUP_3: Begin completions, 5 items -// PROTOCOL_EXT_DEDUP_3: Decl[InstanceMethod]/Super: .foo()[#Int#]; name=foo() -// PROTOCOL_EXT_DEDUP_3: Decl[InstanceVar]/Super: .bar[#Int#]; name=bar -// PROTOCOL_EXT_DEDUP_3: Decl[Subscript]/Super: [{#Self.T#}][#Self.T#]; name=[Self.T] -// PROTOCOL_EXT_DEDUP_3: Keyword[self]/CurrNominal: .self[#T#]; name=self +// PROTOCOL_EXT_DEDUP_3: Decl[InstanceMethod]/CurrNominal: .foo()[#Int#]; name=foo() +// PROTOCOL_EXT_DEDUP_3: Decl[InstanceVar]/CurrNominal: .bar[#Int#]; name=bar +// PROTOCOL_EXT_DEDUP_3: Decl[Subscript]/CurrNominal: [{#Self.T#}][#Self.T#]; name=[Self.T] +// PROTOCOL_EXT_DEDUP_3: Keyword[self]/CurrNominal: .self[#T#]; name=self // PROTOCOL_EXT_DEDUP_3: End completions } diff --git a/test/IDE/complete_where_clause.swift b/test/IDE/complete_where_clause.swift index 0b0af5eea878e..70922c6fae98d 100644 --- a/test/IDE/complete_where_clause.swift +++ b/test/IDE/complete_where_clause.swift @@ -76,8 +76,7 @@ func ab(_ arg: T) where T.#^FUNC_ASSOC_NODUP_1^# func ab(_ arg: T) where T.#^FUNC_ASSOC_NODUP_2^# // GEN_T_ASSOC_E: Begin completions, 2 items -// GEN_T_ASSOC_E-NEXT: Decl[AssociatedType]/Super: E; name=E -// GEN_T_ASSOC_E-NOT: Decl[AssociatedType]/Super: E; name=E +// GEN_T_ASSOC_E-NEXT: Decl[AssociatedType]/{{Super|CurrNominal}}: E; name=E // GEN_T_ASSOC_E-NEXT: Keyword/None: Type[#T.Type#]; // GEN_T_ASSOC_E: End completions @@ -94,7 +93,7 @@ func f2(_: T) where T.#^FUNC_2^# {} // GEN_T_DOT: End completions func f2b(_: T) where T.#^FUNC_2_ASSOC^# {} // GEN_T_ASSOC_DOT: Begin completions -// GEN_T_ASSOC_DOT-DAG: Decl[AssociatedType]/Super: Q; +// GEN_T_ASSOC_DOT-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: Q; // GEN_T_ASSOC_DOT-DAG: Keyword/None: Type[#T.Type#]; // GEN_T_ASSOC_DOT-NOT: Keyword/CurrNominal: self[#T#]; // GEN_T_ASSOC_DOT: End completions @@ -127,9 +126,9 @@ protocol P2 { } // P2: Begin completions -// P2-DAG: Decl[GenericTypeParam]/Super: Self[#Self#]; -// P2-DAG: Decl[AssociatedType]/Super: T; -// P2-DAG: Decl[AssociatedType]/Super: U; +// P2-DAG: Decl[GenericTypeParam]/{{Super|CurrNominal}}: Self[#Self#]; +// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: T; +// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: U; // P2: End completions // U_DOT: Begin completions diff --git a/test/SourceKit/CodeComplete/complete_optionalmethod.swift.response b/test/SourceKit/CodeComplete/complete_optionalmethod.swift.response index ce45a7cd3b4e6..098b1afbe973a 100644 --- a/test/SourceKit/CodeComplete/complete_optionalmethod.swift.response +++ b/test/SourceKit/CodeComplete/complete_optionalmethod.swift.response @@ -6,7 +6,7 @@ key.sourcetext: "optionalMethod?()", key.description: "optionalMethod?()", key.typename: "Int", - key.context: source.codecompletion.context.superclass, + key.context: source.codecompletion.context.thisclass, key.num_bytes_to_erase: 0, key.associated_usrs: "c:@M@complete_optionalmethod@objc(pl)Proto(im)optionalMethod", key.modulename: "complete_optionalmethod" From 0c9aca3da4ccfd2409ecb53b8ca75942782b279b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 19:48:49 -0500 Subject: [PATCH 07/14] IDE: Replace some dead code with an assert --- lib/IDE/CodeCompletion.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 415e6c329f411..0502dce27e7f4 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -3179,19 +3179,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { Kind = LookupKind::ValueExpr; NeedLeadingDot = !HaveDot; - // This is horrible ExprType = ExprType->getRValueType(); + assert(!ExprType->hasTypeParameter()); + this->ExprType = ExprType; - if (ExprType->hasTypeParameter()) { - DeclContext *DC = nullptr; - if (VD) - DC = VD->getInnermostDeclContext(); - else if (auto NTD = ExprType->getInOutObjectType() - ->getMetatypeInstanceType()->getAnyNominal()) - DC = NTD; - if (DC) - ExprType = DC->mapTypeIntoContext(ExprType); - } // Handle special cases bool isIUO = VD && VD->getAttrs() From 3721fc8ca6efc2461d171f2527d9e0f2f0d2768b Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 21:04:12 -0500 Subject: [PATCH 08/14] IDE: Fix a usage of lookupVisibleMemberDecls() to not pass in an existential type It's better to use the 'Self' archetype here. --- lib/IDE/CodeCompletion.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 0502dce27e7f4..89be45800d9f8 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -4177,13 +4177,12 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer { } } - void addDesignatedInitializers(Type CurrTy) { + void addDesignatedInitializers(NominalTypeDecl *NTD) { if (hasFuncIntroducer || hasVarIntroducer || hasTypealiasIntroducer || hasOverridabilityModifier) return; - assert(CurrTy); - const auto *CD = dyn_cast_or_null(CurrTy->getAnyNominal()); + const auto *CD = dyn_cast(NTD); if (!CD) return; if (!CD->hasSuperclass()) @@ -4200,14 +4199,12 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer { } } - void addAssociatedTypes(Type CurrTy) { + void addAssociatedTypes(NominalTypeDecl *NTD) { if (!hasTypealiasIntroducer && (hasFuncIntroducer || hasVarIntroducer || hasInitializerModifier || hasOverride || hasOverridabilityModifier)) return; - NominalTypeDecl *NTD = CurrTy->getAnyNominal(); - for (auto Conformance : NTD->getAllConformances()) { auto Proto = Conformance->getProtocol(); if (!Proto->isAccessibleFrom(CurrDeclContext)) @@ -4233,13 +4230,14 @@ class CompletionOverrideLookup : public swift::VisibleDeclConsumer { if (isa(CurrDeclContext)) return; - Type CurrTy = CurrDeclContext->getDeclaredTypeInContext(); + Type CurrTy = CurrDeclContext->getSelfTypeInContext(); + auto *NTD = CurrDeclContext->getSelfNominalTypeDecl(); if (CurrTy && !CurrTy->is()) { lookupVisibleMemberDecls(*this, CurrTy, CurrDeclContext, TypeResolver, /*includeInstanceMembers=*/false); - addDesignatedInitializers(CurrTy); - addAssociatedTypes(CurrTy); + addDesignatedInitializers(NTD); + addAssociatedTypes(NTD); } } }; From f9154940c213d1d973077eeb94079caaf64a784d Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 21:04:44 -0500 Subject: [PATCH 09/14] IDE: Fix another usage of lookupVisibleMemberDecls() to not pass in an existential type It's better to use the 'Self' archetype here. --- lib/IDE/CodeCompletion.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp index 89be45800d9f8..8bbc5c5bda04a 100644 --- a/lib/IDE/CodeCompletion.cpp +++ b/lib/IDE/CodeCompletion.cpp @@ -3184,6 +3184,21 @@ class CompletionLookup final : public swift::VisibleDeclConsumer { this->ExprType = ExprType; + // Open existential types, so that lookupVisibleMemberDecls() can properly + // substitute them. + bool WasOptional = false; + if (auto OptionalType = ExprType->getOptionalObjectType()) { + ExprType = OptionalType; + WasOptional = true; + } + + if (!ExprType->getMetatypeInstanceType()->isAnyObject()) + if (ExprType->isAnyExistentialType()) + ExprType = ArchetypeType::getAnyOpened(ExprType); + + if (WasOptional) + ExprType = OptionalType::get(ExprType); + // Handle special cases bool isIUO = VD && VD->getAttrs() .hasAttribute(); From 5788ec5ee2ec55e2a7acb3b1be3c4b85bf99d97a Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 23:46:08 -0500 Subject: [PATCH 10/14] LookupVisibleDecls: Process associated types in OverrideFilteringConsumer too --- lib/AST/LookupVisibleDecls.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index a15f2c8138dcd..ffb4cbcf058f4 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -790,7 +790,9 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { // If this kind of declaration doesn't participate in overriding, there's // no filtering to do here. - if (!isa(VD) && !isa(VD)) { + if (!isa(VD) && + !isa(VD) && + !isa(VD)) { DeclsToReport.insert(FoundDeclTy(VD, Reason)); return; } From db2a5ef626bc7e5dfbffb309dba91fddbaa12bbc Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 7 Jan 2019 21:14:11 -0500 Subject: [PATCH 11/14] LookupVisibleDecls: Remove RestateFilteringConsumer It's no longer needed after the previous set of changes, and removing it fixes a crash. Fixes . --- lib/AST/LookupVisibleDecls.cpp | 90 +-------------------------------- test/Sema/typo_correction.swift | 23 ++++++++- 2 files changed, 23 insertions(+), 90 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index ffb4cbcf058f4..4f134782a1a0a 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -471,92 +471,6 @@ lookupVisibleMemberDeclsImpl(Type BaseTy, VisibleDeclConsumer &Consumer, GenericSignatureBuilder *GSB, VisitedSet &Visited); -// Filters out restated declarations from a protocol hierarchy -// or equivalent requirements from protocol composition types. -class RestateFilteringConsumer : public VisibleDeclConsumer { - LazyResolver *resolver; - - using FoundDecl = std::pair; - using NameAndType = std::pair; - - llvm::DenseMap foundVars; - llvm::DenseMap foundFuncs; - llvm::MapVector declsToReport; - - template - void addDecl(llvm::DenseMap &Map, K Key, FoundDecl FD) { - // Add the declaration if we haven't found an equivalent yet, otherwise - // replace the equivalent if the found decl has a higher access level. - auto existingDecl = Map.find(Key); - - if ((existingDecl == Map.end()) || - (Map[Key].first->getFormalAccess() < FD.first->getFormalAccess())) { - if (existingDecl != Map.end()) - declsToReport.erase({existingDecl->getSecond().first}); - Map[Key] = FD; - declsToReport.insert(FD); - } - } - - CanType stripSelfRequirementsIfNeeded(ValueDecl *VD, - GenericFunctionType *GFT) const { - // Preserve the generic signature if this is a subscript, which are uncurried, - // or if we have generic params other than Self. Otherwise, use - // the resultType of the curried function type. - // When we keep the generic signature, we remove the requirements - // from Self to make sure they don't prevent us from recognizing restatements. - auto params = GFT->getGenericParams(); - if (params.size() == 1 && !isa(VD)) { - return GFT->getResult()->getCanonicalType(); - } - auto Self = VD->getDeclContext()->getSelfInterfaceType(); - SmallVector newReqs; - for (auto req: GFT->getRequirements()) { - if (!Self->isEqual(req.getFirstType())) - newReqs.push_back(req); - } - auto newSig = GenericSignature::get(params, newReqs, false); - - return GenericFunctionType::get(newSig, GFT->getParams(), - GFT->getResult(), GFT->getExtInfo()) - ->getCanonicalType(); - } - -public: - RestateFilteringConsumer(Type baseTy, const DeclContext *DC, - LazyResolver *resolver) - : resolver(resolver) { - assert(DC && baseTy && !baseTy->hasLValueType()); - } - - void foundDecl(ValueDecl *VD, DeclVisibilityKind Reason) override { - assert(VD); - // If this isn't a protocol context, don't look further into the decl. - if (!isa(VD->getDeclContext())) { - declsToReport.insert({VD, Reason}); - return; - } - if (resolver) - resolver->resolveDeclSignature(VD); - - if (!VD->hasInterfaceType()) { - declsToReport.insert({VD, Reason}); - return; - } - if (auto GFT = VD->getInterfaceType()->getAs()) { - auto type = stripSelfRequirementsIfNeeded(VD, GFT); - addDecl(foundFuncs, {VD->getFullName(), type}, {VD, Reason}); - return; - } - addDecl(foundVars, VD->getFullName(), {VD, Reason}); - } - - void feedResultsToConsumer(VisibleDeclConsumer &Consumer) const { - for (const auto entry: declsToReport) - Consumer.foundDecl(entry.first, entry.second); - } -}; - static void lookupVisibleProtocolMemberDecls(Type BaseTy, ProtocolType *PT, VisibleDeclConsumer &Consumer, @@ -916,13 +830,11 @@ static void lookupVisibleMemberDecls( LookupState LS, DeclVisibilityKind Reason, LazyResolver *TypeResolver, GenericSignatureBuilder *GSB) { OverrideFilteringConsumer overrideConsumer(BaseTy, CurrDC, TypeResolver); - RestateFilteringConsumer restateConsumer(BaseTy, CurrDC, TypeResolver); VisitedSet Visited; - lookupVisibleMemberDeclsImpl(BaseTy, restateConsumer, CurrDC, LS, Reason, + lookupVisibleMemberDeclsImpl(BaseTy, overrideConsumer, CurrDC, LS, Reason, TypeResolver, GSB, Visited); // Report the declarations we found to the real consumer. - restateConsumer.feedResultsToConsumer(overrideConsumer); for (const auto &DeclAndReason : overrideConsumer.DeclsToReport) Consumer.foundDecl(DeclAndReason.D, DeclAndReason.Reason); } diff --git a/test/Sema/typo_correction.swift b/test/Sema/typo_correction.swift index af9010bd28bde..c011bd11c618a 100644 --- a/test/Sema/typo_correction.swift +++ b/test/Sema/typo_correction.swift @@ -113,10 +113,12 @@ struct Generic { } protocol P { // expected-note {{'P' previously declared here}} + // expected-note@-1 {{did you mean 'P'?}} typealias a = Generic } protocol P {} // expected-error {{invalid redeclaration of 'P'}} +// expected-note@-1 {{did you mean 'P'?}} func hasTypo() { _ = P.a.a // expected-error {{type 'P.a' (aka 'Generic') has no member 'a'}} @@ -170,7 +172,7 @@ class CircularValidationWithTypo { // Crash with invalid extension that has not been bound -- https://bugs.swift.org/browse/SR-8984 protocol PP {} -func boo() { // expected-note {{did you mean 'boo'?}} +func boo() { extension PP { // expected-error {{declaration is only valid at file scope}} func g() { booo() // expected-error {{use of unresolved identifier 'booo'}} @@ -197,3 +199,22 @@ func testFwdRef() { let _ = forward_refX + 1 // expected-error {{use of unresolved identifier 'forward_refX'}} let forward_ref1 = 4 } + +// Crash with protocol members. +protocol P1 { + associatedtype A1 + associatedtype A2 +} + +protocol P2 { + associatedtype A1 + associatedtype A2 + + func method(_: T) where T.A1 == A1, T.A2 == A2 +} + +extension P2 { + func f() { // expected-note {{did you mean 'f'?}} + _ = a // expected-error {{use of unresolved identifier 'a'}} + } +} From 3f1d641902f9ebdf8f55be4a0c428fc9472e54c6 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 8 Jan 2019 15:31:29 -0500 Subject: [PATCH 12/14] LookupVisibleDecls: Fix duplicate completion results when inheritance is used with protocol conformance Consider this setup: protocol Proto { func foo() {} } class Base : Proto { func foo() {} } class Derived : Base { ... } When completing members of a Derived instance, we find both the protocol's foo() and the base class's foo(). These have the following types: - Proto.foo: (Self) -> () -> () - Base.foo: (Base) -> () -> () If we simply substitute the base type (Derived) into the type of the protocol member, we get (Derived) -> () -> (), which is different than the type of Base.foo, so we get both declarations in the completion list. Instead, use the 'Self' type for the specific class of the conformance, which in this case is 'Base' even if we're looking at members of 'Derived'. Fixes , . --- lib/AST/LookupVisibleDecls.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 4f134782a1a0a..125373cd4551b 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -679,6 +679,23 @@ template <> struct DenseMapInfo { } // namespace llvm +// If a class 'Base' conforms to 'Proto', and my base type is a subclass +// 'Derived' of 'Base', use 'Base' not 'Derived' as the 'Self' type in the +// substitution map. +static Type getBaseTypeForMember(ModuleDecl *M, ValueDecl *OtherVD, Type BaseTy) { + if (auto *Proto = OtherVD->getDeclContext()->getSelfProtocolDecl()) { + if (BaseTy->getClassOrBoundGenericClass()) { + if (auto Conformance = M->lookupConformance(BaseTy, Proto)) { + auto *Superclass = Conformance->getConcrete()->getRootConformance() + ->getType()->getClassOrBoundGenericClass(); + return BaseTy->getSuperclassForDecl(Superclass); + } + } + } + + return BaseTy; +} + namespace { class OverrideFilteringConsumer : public VisibleDeclConsumer { @@ -789,7 +806,8 @@ class OverrideFilteringConsumer : public VisibleDeclConsumer { auto OtherSignature = OtherVD->getOverloadSignature(); auto OtherSignatureType = OtherVD->getOverloadSignatureType(); if (OtherSignatureType && shouldSubst) { - auto subs = BaseTy->getMemberSubstitutionMap(M, OtherVD); + auto ActualBaseTy = getBaseTypeForMember(M, OtherVD, BaseTy); + auto subs = ActualBaseTy->getMemberSubstitutionMap(M, OtherVD); if (auto CT = OtherSignatureType.subst(subs)) OtherSignatureType = CT->getCanonicalType(); } From 483749d2b8af6ce3bac84a9f19063a148a253967 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 8 Jan 2019 16:02:50 -0500 Subject: [PATCH 13/14] LookupVisibleDecls: Find generic parameters in methods inside extensions The logic here had diverged from UnqualifiedLookup. One day we'll merge the two, for now clean it up a bit to match. Note that all generic parameters now have 'Reason' reported as 'Local'. I don't believe this really matters. Fixes . --- lib/AST/LookupVisibleDecls.cpp | 45 +++++++++++++--------- test/IDE/complete_crashes.swift | 2 +- test/IDE/complete_expr_postfix_begin.swift | 26 ++++++------- test/IDE/complete_init.swift | 5 ++- test/IDE/complete_pattern.swift | 6 +-- test/IDE/complete_type.swift | 44 ++++++++++----------- test/IDE/complete_type_subscript.swift | 2 +- test/IDE/complete_where_clause.swift | 8 ++-- 8 files changed, 73 insertions(+), 65 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 125373cd4551b..189420b57df94 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -230,27 +230,8 @@ static void lookupTypeMembers(Type BaseType, Type LookupType, NominalTypeDecl *D = LookupType->getAnyNominal(); assert(D && "should have a nominal type"); - bool LookupFromChildDeclContext = false; - const DeclContext *TempDC = CurrDC; - while (!TempDC->isModuleContext()) { - if (TempDC == D) { - LookupFromChildDeclContext = true; - break; - } - TempDC = TempDC->getParent(); - } - SmallVector FoundDecls; - if (LookupFromChildDeclContext) { - // Current decl context is contained inside 'D', so generic parameters - // are visible. - if (D->getGenericParams()) - for (auto Param : *D->getGenericParams()) - if (isDeclVisibleInLookupMode(Param, LS, CurrDC, TypeResolver)) - FoundDecls.push_back(Param); - } - for (Decl *Member : D->getMembers()) { if (auto *VD = dyn_cast(Member)) if (isDeclVisibleInLookupMode(VD, LS, CurrDC, TypeResolver)) @@ -868,6 +849,7 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, // If we are inside of a method, check to see if there are any ivars in scope, // and if so, whether this is a reference to one of them. while (!DC->isModuleScopeContext()) { + GenericParamList *GenericParams = nullptr; const ValueDecl *BaseDecl = nullptr; Type ExtendedType; auto LS = LookupState::makeUnqualified(); @@ -911,6 +893,8 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, namelookup::FindLocalVal(SM, Loc, Consumer).checkParameterList( AFD->getParameters()); + GenericParams = AFD->getGenericParams(); + if (AFD->getDeclContext()->isTypeContext()) { ExtendedType = AFD->getDeclContext()->getSelfTypeInContext(); BaseDecl = AFD->getImplicitSelfDecl(); @@ -936,6 +920,29 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, BaseDecl = ND; } + // If we're inside a function context, we've already moved to + // the parent DC, so we have to check the function's generic + // parameters first. + if (GenericParams) { + namelookup::FindLocalVal localVal(SM, Loc, Consumer); + localVal.checkGenericParams(GenericParams); + } + + // Check the generic parameters of our context. + GenericParamList *dcGenericParams = nullptr; + if (auto nominal = dyn_cast(DC)) + dcGenericParams = nominal->getGenericParams(); + else if (auto ext = dyn_cast(DC)) + dcGenericParams = ext->getGenericParams(); + else if (auto subscript = dyn_cast(DC)) + dcGenericParams = subscript->getGenericParams(); + + while (dcGenericParams) { + namelookup::FindLocalVal localVal(SM, Loc, Consumer); + localVal.checkGenericParams(dcGenericParams); + dcGenericParams = dcGenericParams->getOuterParameters(); + } + if (BaseDecl && ExtendedType) ::lookupVisibleMemberDecls(ExtendedType, Consumer, DC, LS, Reason, TypeResolver, nullptr); diff --git a/test/IDE/complete_crashes.swift b/test/IDE/complete_crashes.swift index dce4cfe8dc22a..b2711e2d0054c 100644 --- a/test/IDE/complete_crashes.swift +++ b/test/IDE/complete_crashes.swift @@ -68,7 +68,7 @@ while true { struct CustomGenericCollection : ExpressibleByDictionaryLiteral { // GENERIC_PARAM_AND_ASSOC_TYPE: Begin completions // GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[InstanceVar]/CurrNominal: count[#Int#]; name=count - // GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[GenericTypeParam]/CurrNominal: Key[#Key#]; name=Key + // GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[GenericTypeParam]/Local: Key[#Key#]; name=Key // GENERIC_PARAM_AND_ASSOC_TYPE-DAG: Decl[TypeAlias]/CurrNominal: Value[#CustomGenericCollection.Value#]; name=Value // GENERIC_PARAM_AND_ASSOC_TYPE: End completions diff --git a/test/IDE/complete_expr_postfix_begin.swift b/test/IDE/complete_expr_postfix_begin.swift index d1fef816733dc..83a9727e369b4 100644 --- a/test/IDE/complete_expr_postfix_begin.swift +++ b/test/IDE/complete_expr_postfix_begin.swift @@ -228,7 +228,7 @@ struct TestFindFuncParam5_6 { func testFindFuncParam5(a: Int, b: T) { #^FIND_FUNC_PARAM_5^# // FIND_FUNC_PARAM_5: Begin completions -// FIND_FUNC_PARAM_5-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]{{; name=.+$}} +// FIND_FUNC_PARAM_5-DAG: Decl[GenericTypeParam]/Local: T[#T#]{{; name=.+$}} // FIND_FUNC_PARAM_5-DAG: Decl[LocalVar]/Local: self[#TestFindFuncParam5_6#]{{; name=.+$}} // FIND_FUNC_PARAM_5-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} // FIND_FUNC_PARAM_5-DAG: Decl[LocalVar]/Local: b[#T#]{{; name=.+$}} @@ -238,7 +238,7 @@ struct TestFindFuncParam5_6 { func testFindFuncParam6(a: Int, b: T, c: U) { #^FIND_FUNC_PARAM_6^# // FIND_FUNC_PARAM_6: Begin completions -// FIND_FUNC_PARAM_6-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]{{; name=.+$}} +// FIND_FUNC_PARAM_6-DAG: Decl[GenericTypeParam]/Local: T[#T#]{{; name=.+$}} // FIND_FUNC_PARAM_6-DAG: Decl[GenericTypeParam]/Local: U[#U#]{{; name=.+$}} // FIND_FUNC_PARAM_6-DAG: Decl[LocalVar]/Local: self[#TestFindFuncParam5_6#]{{; name=.+$}} // FIND_FUNC_PARAM_6-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} @@ -309,10 +309,10 @@ class TestFindConstructorParam4 { init(a: Int, b: T) { #^FIND_CONSTRUCTOR_PARAM_4^# // FIND_CONSTRUCTOR_PARAM_4: Begin completions -// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: self[#TestFindConstructorParam4#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: b[#T#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[GenericTypeParam]/Local: T[#T#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: self[#TestFindConstructorParam4#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_4-DAG: Decl[LocalVar]/Local: b[#T#]{{; name=.+$}} // FIND_CONSTRUCTOR_PARAM_4: End completions } } @@ -321,12 +321,12 @@ class TestFindConstructorParam5 { init(a: Int, b: T, c: U) { #^FIND_CONSTRUCTOR_PARAM_5^# // FIND_CONSTRUCTOR_PARAM_5: Begin completions -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[GenericTypeParam]/Local: U[#U#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: self[#TestFindConstructorParam5#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: b[#T#]{{; name=.+$}} -// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: c[#U#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[GenericTypeParam]/Local: T[#T#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[GenericTypeParam]/Local: U[#U#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: self[#TestFindConstructorParam5#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: a[#Int#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: b[#T#]{{; name=.+$}} +// FIND_CONSTRUCTOR_PARAM_5-DAG: Decl[LocalVar]/Local: c[#U#]{{; name=.+$}} // FIND_CONSTRUCTOR_PARAM_5: End completions } } @@ -357,7 +357,7 @@ class TestFindDestructorParam2 { deinit { #^FIND_DESTRUCTOR_PARAM_2^# // FIND_DESTRUCTOR_PARAM_2: Begin completions -// FIND_DESTRUCTOR_PARAM_2-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]{{; name=.+$}} +// FIND_DESTRUCTOR_PARAM_2-DAG: Decl[GenericTypeParam]/Local: T[#T#]{{; name=.+$}} // FIND_DESTRUCTOR_PARAM_2-DAG: Decl[LocalVar]/Local: self[#TestFindDestructorParam2#]{{; name=.+$}} // FIND_DESTRUCTOR_PARAM_2: End completions } diff --git a/test/IDE/complete_init.swift b/test/IDE/complete_init.swift index ad9d5aa53f1a8..e7882e535902b 100644 --- a/test/IDE/complete_init.swift +++ b/test/IDE/complete_init.swift @@ -124,7 +124,8 @@ extension L { // INSIDE_L_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}} // FIXME: Code complete generic parameters in extensions -// disabled_INSIDE_L_0-DAG: Decl[Constructor]/CurrNominal: X({#x: A#})[#X#]{{; name=.+}} +// INSIDE_L_0-DAG: Decl[GenericTypeParam]/Local: X[#X#]; name=X +// INSIDE_L_0-DAG: Decl[Constructor]/Local: X({#x: A#})[#G#]{{; name=.+}} // INSIDE_L_0: End completions @@ -136,7 +137,7 @@ struct M { } // INSIDE_M_0: Begin completions // INSIDE_M_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}} -// INSIDE_M_0-DAG: Decl[Constructor]/CurrNominal: X({#x: A#})[#G#]{{; name=.+}} +// INSIDE_M_0-DAG: Decl[Constructor]/Local: X({#x: A#})[#G#]{{; name=.+}} // INSIDE_M_0: End completions typealias CAlias = C diff --git a/test/IDE/complete_pattern.swift b/test/IDE/complete_pattern.swift index d865a799c38fb..32049bf35b674 100644 --- a/test/IDE/complete_pattern.swift +++ b/test/IDE/complete_pattern.swift @@ -198,9 +198,9 @@ struct PatternIsGeneric2< // PATTERN_IS_GENERIC_2: Begin completions // Generic parameters of the struct. -// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // Generic parameters of the function. // PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: GenericFoo[#GenericFoo#]{{; name=.+$}} // PATTERN_IS_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: GenericBar[#GenericBar#]{{; name=.+$}} diff --git a/test/IDE/complete_type.swift b/test/IDE/complete_type.swift index d6960fd528bff..025e33f465766 100644 --- a/test/IDE/complete_type.swift +++ b/test/IDE/complete_type.swift @@ -456,7 +456,7 @@ typealias FooTypealias = Int //===--- // TYPE_IN_PROTOCOL: Begin completions -// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/CurrNominal: Self[#Self#]{{; name=.+$}} +// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/Local: Self[#Self#]{{; name=.+$}} // TYPE_IN_PROTOCOL: End completions protocol TestSelf1 { @@ -488,9 +488,9 @@ struct TestTypeInParamGeneric2< } // TYPE_IN_FUNC_PARAM_GENERIC_2: Begin completions -// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_2-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // TYPE_IN_FUNC_PARAM_GENERIC_2: End completions struct TestTypeInParamGeneric3 { @@ -518,9 +518,9 @@ struct TestTypeInParamGeneric4< // TYPE_IN_FUNC_PARAM_GENERIC_4: Begin completions // Generic parameters of the struct. -// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // Generic parameters of the function. // TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/Local: GenericFoo[#GenericFoo#]{{; name=.+$}} // TYPE_IN_FUNC_PARAM_GENERIC_4-DAG: Decl[GenericTypeParam]/Local: GenericBar[#GenericBar#]{{; name=.+$}} @@ -537,9 +537,9 @@ struct TestTypeInParamGeneric5 { // TYPE_IN_FUNC_PARAM_GENERIC_5: Begin completions // Generic parameters of the containing structs. -// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/OutNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/OutNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // Generic parameters of the function. // TYPE_IN_FUNC_PARAM_GENERIC_5-DAG: Decl[GenericTypeParam]/Local: GenericFoo[#GenericFoo#]{{; name=.+$}} // TYPE_IN_FUNC_PARAM_GENERIC_5: End completions @@ -552,9 +552,9 @@ struct TestTypeInConstructorParamGeneric1< } // TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1: Begin completions -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_1: End completions struct TestTypeInConstructorParamGeneric2 { @@ -580,9 +580,9 @@ struct TestTypeInConstructorParamGeneric3< // TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3: Begin completions // Generic parameters of the struct. -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBar[#StructGenericBar#]{{; name=.+$}} -// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/CurrNominal: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/Local: StructGenericFoo[#StructGenericFoo#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/Local: StructGenericBar[#StructGenericBar#]{{; name=.+$}} +// TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/Local: StructGenericBaz[#StructGenericBaz#]{{; name=.+$}} // Generic parameters of the constructor. // TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/Local: GenericFoo[#GenericFoo#]{{; name=.+$}} // TYPE_IN_CONSTRUCTOR_PARAM_GENERIC_3-DAG: Decl[GenericTypeParam]/Local: GenericBar[#GenericBar#]{{; name=.+$}} @@ -605,18 +605,18 @@ class A { } // TYPE_IN_RETURN_GEN_PARAM_NO_DUP: Begin completions -// TYPE_IN_RETURN_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]; name=T -// TYPE_IN_RETURN_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IN_RETURN_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IN_RETURN_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T // TYPE_IN_RETURN_GEN_PARAM_NO_DUP: End completions // TYPE_IVAR_GEN_PARAM_NO_DUP: Begin completions -// TYPE_IVAR_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]; name=T -// TYPE_IVAR_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IVAR_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IVAR_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T // TYPE_IVAR_GEN_PARAM_NO_DUP: End completions // TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP: Begin completions -// TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/CurrNominal: T[#T#]; name=T -// TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP-DAG: Decl[GenericTypeParam]/Local: T[#T#]; name=T +// TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP-NOT: Decl[GenericTypeParam]/Local: T[#T#]; name=T // TYPE_IN_SUBSCR_GEN_PARAM_NO_DUP: End completions //===--- diff --git a/test/IDE/complete_type_subscript.swift b/test/IDE/complete_type_subscript.swift index 707443d3ba385..e93fcf59a96e6 100644 --- a/test/IDE/complete_type_subscript.swift +++ b/test/IDE/complete_type_subscript.swift @@ -40,7 +40,7 @@ struct G0 { subscript(x: T) -> #^GEN_RETURN_0^# { return 0 } } // GEN_TOP_LEVEL_0: Keyword/None: Any[#Any#]; -// GEN_TOP_LEVEL_0: Decl[GenericTypeParam]/CurrNominal: T[#T#]; name=T +// GEN_TOP_LEVEL_0: Decl[GenericTypeParam]/Local: T[#T#]; name=T // GEN_TOP_LEVEL_0: Decl[Struct]/CurrModule: S0[#S0#]; // GEN_TOP_LEVEL_0: Decl[Struct]/OtherModule[Swift]: Int[#Int#]; diff --git a/test/IDE/complete_where_clause.swift b/test/IDE/complete_where_clause.swift index 70922c6fae98d..6b48840ff7a66 100644 --- a/test/IDE/complete_where_clause.swift +++ b/test/IDE/complete_where_clause.swift @@ -118,7 +118,7 @@ class C1 where #^CLASS_1^# {} class C2 where T.#^CLASS_2^# {} enum E1 where #^ENUM_1^# {} enum E2 where T.#^ENUM_2^# {} -// GEN_T_NOMINAL: Decl[GenericTypeParam]/CurrNominal: T[#T#]; name=T +// GEN_T_NOMINAL: Decl[GenericTypeParam]/Local: T[#T#]; name=T protocol P2 { associatedtype T where #^ASSOC_1^# @@ -126,9 +126,9 @@ protocol P2 { } // P2: Begin completions -// P2-DAG: Decl[GenericTypeParam]/{{Super|CurrNominal}}: Self[#Self#]; -// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: T; -// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: U; +// P2-DAG: Decl[GenericTypeParam]/Local: Self[#Self#]; +// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: T; +// P2-DAG: Decl[AssociatedType]/{{Super|CurrNominal}}: U; // P2: End completions // U_DOT: Begin completions From 19186bb71b4dd56f1ccc369472888b0c5c5b1800 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 8 Jan 2019 16:07:27 -0500 Subject: [PATCH 14/14] LookupVisibleDecls: Remove an unused variable --- lib/AST/LookupVisibleDecls.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/AST/LookupVisibleDecls.cpp b/lib/AST/LookupVisibleDecls.cpp index 189420b57df94..c44676dee170b 100644 --- a/lib/AST/LookupVisibleDecls.cpp +++ b/lib/AST/LookupVisibleDecls.cpp @@ -850,7 +850,6 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, // and if so, whether this is a reference to one of them. while (!DC->isModuleScopeContext()) { GenericParamList *GenericParams = nullptr; - const ValueDecl *BaseDecl = nullptr; Type ExtendedType; auto LS = LookupState::makeUnqualified(); @@ -874,7 +873,6 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, if (auto *SE = dyn_cast(DC)) { ExtendedType = SE->getDeclContext()->getSelfTypeInContext(); DC = DC->getParent(); - BaseDecl = DC->getSelfNominalTypeDecl(); } else if (auto *AFD = dyn_cast(DC)) { // Look for local variables; normally, the parser resolves these @@ -897,7 +895,6 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, if (AFD->getDeclContext()->isTypeContext()) { ExtendedType = AFD->getDeclContext()->getSelfTypeInContext(); - BaseDecl = AFD->getImplicitSelfDecl(); DC = DC->getParent(); if (auto *FD = dyn_cast(AFD)) @@ -913,11 +910,8 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, } } else if (auto ED = dyn_cast(DC)) { ExtendedType = ED->getSelfTypeInContext(); - if (ExtendedType) - BaseDecl = ExtendedType->getNominalOrBoundGenericNominal(); } else if (auto ND = dyn_cast(DC)) { ExtendedType = ND->getSelfTypeInContext(); - BaseDecl = ND; } // If we're inside a function context, we've already moved to @@ -943,7 +937,7 @@ static void lookupVisibleDeclsImpl(VisibleDeclConsumer &Consumer, dcGenericParams = dcGenericParams->getOuterParameters(); } - if (BaseDecl && ExtendedType) + if (ExtendedType) ::lookupVisibleMemberDecls(ExtendedType, Consumer, DC, LS, Reason, TypeResolver, nullptr);