Skip to content

Commit 0cc9f6c

Browse files
committed
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 <T : P & Q>, 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).
1 parent c2bb58d commit 0cc9f6c

8 files changed

+99
-89
lines changed

lib/AST/LookupVisibleDecls.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,12 +642,11 @@ static void lookupVisibleMemberDeclsImpl(
642642
for (auto Proto : Archetype->getConformsTo())
643643
lookupVisibleProtocolMemberDecls(
644644
BaseTy, Proto->getDeclaredType(), Consumer, CurrDC, LS,
645-
getReasonForSuper(Reason), TypeResolver, GSB, Visited);
645+
Reason, TypeResolver, GSB, Visited);
646646

647647
if (auto superclass = Archetype->getSuperclass())
648648
lookupVisibleMemberDeclsImpl(superclass, Consumer, CurrDC, LS,
649-
getReasonForSuper(Reason), TypeResolver,
650-
GSB, Visited);
649+
Reason, TypeResolver, GSB, Visited);
651650
return;
652651
}
653652

test/IDE/complete_members_optional.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ func optionalMembers1(_ a: HasOptionalMembers1) {
2929
a.#^OPTIONAL_MEMBERS_1^#
3030
}
3131
// OPTIONAL_MEMBERS_1: Begin completions, 3 items
32-
// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?()[#Int#]{{; name=.+$}}
33-
// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceVar]/CurrNominal: optionalInstanceProperty[#Int?#]{{; name=.+$}}
32+
// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?()[#Int#]{{; name=.+$}}
33+
// OPTIONAL_MEMBERS_1-DAG: Decl[InstanceVar]/CurrNominal: optionalInstanceProperty[#Int?#]{{; name=.+$}}
3434
// OPTIONAL_MEMBERS_1-DAG: Keyword[self]/CurrNominal: self[#HasOptionalMembers1#]; name=self
3535
// OPTIONAL_MEMBERS_1: End completions
3636

3737
func optionalMembers2<T : HasOptionalMembers1>(_ a: T) {
3838
T.#^OPTIONAL_MEMBERS_2^#
3939
}
4040
// OPTIONAL_MEMBERS_2: Begin completions, 4 items
41-
// OPTIONAL_MEMBERS_2-DAG: Decl[InstanceMethod]/Super: optionalInstanceFunc?({#self: HasOptionalMembers1#})[#() -> Int#]{{; name=.+$}}
42-
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticMethod]/Super: optionalClassFunc?()[#Int#]{{; name=.+$}}
43-
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticVar]/Super: optionalClassProperty[#Int?#]{{; name=.+$}}
41+
// OPTIONAL_MEMBERS_2-DAG: Decl[InstanceMethod]/CurrNominal: optionalInstanceFunc?({#self: HasOptionalMembers1#})[#() -> Int#]{{; name=.+$}}
42+
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticMethod]/CurrNominal: optionalClassFunc?()[#Int#]{{; name=.+$}}
43+
// OPTIONAL_MEMBERS_2-DAG: Decl[StaticVar]/CurrNominal: optionalClassProperty[#Int?#]{{; name=.+$}}
4444
// OPTIONAL_MEMBERS_2-DAG: Keyword[self]/CurrNominal: self[#T.Type#]; name=self
4545
// OPTIONAL_MEMBERS_2: End completions

test/IDE/complete_operators.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ func testInfix15<T: P where T.T == S2>() {
279279
T#^INFIX_15^#
280280
}
281281
// INFIX_15: Begin completions, 3 items
282-
// INFIX_15-NEXT: Decl[AssociatedType]/Super: .T; name=T
283-
// INFIX_15-NEXT: Decl[InstanceMethod]/Super: .foo({#self: P#})[#() -> S2#]; name=foo(P)
282+
// INFIX_15-NEXT: Decl[AssociatedType]/CurrNominal: .T; name=T
283+
// INFIX_15-NEXT: Decl[InstanceMethod]/CurrNominal: .foo({#self: P#})[#() -> S2#]; name=foo(P)
284284
// INFIX_15-NEXT: Keyword[self]/CurrNominal: .self[#T.Type#]; name=self
285285
// INFIX_15: End completions
286286

test/IDE/complete_type.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ typealias FooTypealias = Int
456456
//===---
457457

458458
// TYPE_IN_PROTOCOL: Begin completions
459-
// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/Super: Self[#Self#]{{; name=.+$}}
459+
// TYPE_IN_PROTOCOL-DAG: Decl[GenericTypeParam]/CurrNominal: Self[#Self#]{{; name=.+$}}
460460
// TYPE_IN_PROTOCOL: End completions
461461

462462
protocol TestSelf1 {
@@ -1013,7 +1013,7 @@ func testTypeIdentifierGeneric1<
10131013
>(a: GenericFoo.#^TYPE_IDENTIFIER_GENERIC_1^#
10141014

10151015
// TYPE_IDENTIFIER_GENERIC_1: Begin completions
1016-
// TYPE_IDENTIFIER_GENERIC_1-NEXT: Decl[AssociatedType]/Super: FooTypeAlias1{{; name=.+$}}
1016+
// TYPE_IDENTIFIER_GENERIC_1-NEXT: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}}
10171017
// TYPE_IDENTIFIER_GENERIC_1-NEXT: Keyword/None: Type[#GenericFoo.Type#]
10181018
// TYPE_IDENTIFIER_GENERIC_1-NEXT: End completions
10191019

@@ -1022,8 +1022,8 @@ func testTypeIdentifierGeneric2<
10221022
>(a: GenericFoo.#^TYPE_IDENTIFIER_GENERIC_2^#
10231023

10241024
// TYPE_IDENTIFIER_GENERIC_2: Begin completions
1025-
// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/Super: BarTypeAlias1{{; name=.+$}}
1026-
// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/Super: FooTypeAlias1{{; name=.+$}}
1025+
// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/CurrNominal: BarTypeAlias1{{; name=.+$}}
1026+
// TYPE_IDENTIFIER_GENERIC_2-NEXT: Decl[AssociatedType]/CurrNominal: FooTypeAlias1{{; name=.+$}}
10271027
// TYPE_IDENTIFIER_GENERIC_2-NEXT: Keyword/None: Type[#GenericFoo.Type#]
10281028
// TYPE_IDENTIFIER_GENERIC_2-NEXT: End completions
10291029

test/IDE/complete_type_subscript.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ extension G6 {
100100
subscript(b x: T.#^GEN_EXT_PARAM_6^#) -> Int { return 0 }
101101
subscript(b x: Int) -> T.#^GEN_EXT_RETURN_6^# { return 0 }
102102
}
103-
// GEN_PARAM_6-DAG: Decl[AssociatedType]/Super: Assoc;
103+
// GEN_PARAM_6-DAG: Decl[AssociatedType]/CurrNominal: Assoc;
104104
// GEN_PARAM_6-DAG: Keyword/None: Type[#T.Type#];
105105

106106
// 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 {
116116
subscript(b x: I.#^GENPROTO_EXT_PARAM_1^#) -> Int { return 1 }
117117
subscript(b x: Int) -> I.#^GENPROTO_EXT_RETURN_1^# { return 1 }
118118
}
119-
// GENPROTO_1-DAG: Decl[AssociatedType]/Super: Assoc;
119+
// GENPROTO_1-DAG: Decl[AssociatedType]/CurrNominal: Assoc;
120120
// GENPROTO_1-DAG: Keyword/None: Type[#Self.I.Type#];

0 commit comments

Comments
 (0)