Skip to content

Commit 72975a3

Browse files
authored
Merge pull request #16968 from AnthonyLatsis/code-compl-no-self-for-type-syntax
[CodeCompletion] Remove 'self' from type identifier completions
2 parents 9c5525a + 9d5302e commit 72975a3

File tree

5 files changed

+6
-12
lines changed

5 files changed

+6
-12
lines changed

lib/IDE/CodeCompletion.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4151,7 +4151,6 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
41514151
CurrDeclContext, TypeResolver.get(),
41524152
IncludeInstanceMembers);
41534153
addKeyword("Type", MetaBase);
4154-
addKeyword("self", BaseType, SemanticContextKind::CurrentNominal);
41554154
}
41564155

41574156
static bool canUseAttributeOnDecl(DeclAttrKind DAK, bool IsInSil,

test/IDE/complete_associated_types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func testStruct2() {
177177
func testStruct3(a: StructWithAssociatedTypes) {
178178
a.#^STRUCT_INSTANCE^#
179179
}
180-
// STRUCT_TYPE_COUNT: Begin completions, 26 items
180+
// STRUCT_TYPE_COUNT: Begin completions, 25 items
181181

182182
// STRUCT_INSTANCE: Begin completions, 15 items
183183
// STRUCT_INSTANCE-DAG: Decl[InstanceMethod]/CurrNominal: deduceCommonA()[#Int#]

test/IDE/complete_type.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ func testTypeIdentifierGeneric3<
10241024

10251025
// TYPE_IDENTIFIER_GENERIC_3: Begin completions
10261026
// TYPE_IDENTIFIER_GENERIC_3-NEXT: Keyword/None: Type[#GenericFoo.Type#]
1027-
// TYPE_IDENTIFIER_GENERIC_3-NEXT: Keyword/CurrNominal: self[#GenericFoo#]
1027+
// TYPE_IDENTIFIER_GENERIC_3-NOT: Keyword/CurrNominal: self[#GenericFoo#]
10281028
// TYPE_IDENTIFIER_GENERIC_3-NEXT: End completions
10291029

10301030
func testTypeIdentifierIrrelevant1() {

test/IDE/complete_type_subscript.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ struct S1 {
1717
subscript(x: MyStruct) -> MyStruct#^RETURN_1^# { }
1818
}
1919
// MYSTRUCT_0: Keyword/None: .Type[#S1.MyStruct.Type#];
20-
// MYSTRUCT_0: Keyword/CurrNominal: .self[#S1.MyStruct#];
2120

2221

2322
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=PARAM_2 | %FileCheck %s -check-prefix=MYSTRUCT_1
@@ -28,7 +27,7 @@ struct S2 {
2827
subscript(x: MyStruct) -> MyStruct.#^RETURN_2^# { }
2928
}
3029
// MYSTRUCT_1: Keyword/None: Type[#S2.MyStruct.Type#];
31-
// MYSTRUCT_1: Keyword/CurrNominal: self[#S2.MyStruct#];
30+
// MYSTRUCT_1-NOT: Keyword/CurrNominal: self[#S2.MyStruct#];
3231

3332
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_PARAM_0 | %FileCheck %s -check-prefix=GEN_TOP_LEVEL_0
3433
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_RETURN_0 | %FileCheck %s -check-prefix=GEN_TOP_LEVEL_0
@@ -48,7 +47,6 @@ struct G1<T> {
4847
subscript(x: T) -> T#^GEN_RETURN_1^# { return 0 }
4948
}
5049
// GEN_PARAM_1: Keyword/None: .Type[#T.Type#];
51-
// GEN_PARAM_1: Keyword/CurrNominal: .self[#T#];
5250

5351
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_PARAM_2 | %FileCheck %s -check-prefix=GEN_PARAM_2
5452
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_RETURN_2 | %FileCheck %s -check-prefix=GEN_PARAM_2
@@ -57,7 +55,6 @@ struct G2<T> {
5755
subscript(x: T) -> T.#^GEN_RETURN_2^# { return 0 }
5856
}
5957
// GEN_PARAM_2: Keyword/None: Type[#T.Type#];
60-
// GEN_PARAM_2: Keyword/CurrNominal: self[#T#];
6158

6259
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_PARAM_3 | %FileCheck %s -check-prefix=GEN_TOP_LEVEL_1
6360
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_RETURN_3 | %FileCheck %s -check-prefix=GEN_TOP_LEVEL_1
@@ -77,7 +74,6 @@ struct G4 {
7774
subscript<T>(x: T) -> T#^GEN_RETURN_4^# { return 0 }
7875
}
7976
// GEN_PARAM_4: Keyword/None: .Type[#T.Type#];
80-
// GEN_PARAM_4: Keyword/CurrNominal: .self[#T#];
8177

8278
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_PARAM_5 | %FileCheck %s -check-prefix=GEN_PARAM_5
8379
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GEN_RETURN_5 | %FileCheck %s -check-prefix=GEN_PARAM_5
@@ -86,4 +82,4 @@ struct G5 {
8682
subscript<T>(x: T) -> T.#^GEN_RETURN_5^# { return 0 }
8783
}
8884
// GEN_PARAM_5: Keyword/None: Type[#T.Type#];
89-
// GEN_PARAM_5: Keyword/CurrNominal: self[#T#];
85+
// GEN_PARAM_5-NOT: Keyword/CurrNominal: self[#T#];

test/IDE/complete_where_clause.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func f1<T>(_: T) where #^FUNC_1^# {}
7272
func f2<T>(_: T) where T.#^FUNC_2^# {}
7373
// GEN_T_DOT: Begin completions
7474
// GEN_T_DOT-DAG: Keyword/None: Type[#T.Type#];
75-
// GEN_T_DOT-DAG: Keyword/CurrNominal: self[#T#];
75+
// GEN_T_DOT-NOT: Keyword/CurrNominal: self[#T#];
7676
// GEN_T_DOT: End completions
7777
func f2b<T: Assoc>(_: T) where T.#^FUNC_2_ASSOC^# {}
7878
// GEN_T_ASSOC_DOT: Begin completions
7979
// GEN_T_ASSOC_DOT-DAG: Decl[AssociatedType]/Super: Q;
8080
// GEN_T_ASSOC_DOT-DAG: Keyword/None: Type[#T.Type#];
81-
// GEN_T_ASSOC_DOT-DAG: Keyword/CurrNominal: self[#T#];
81+
// GEN_T_ASSOC_DOT-NOT: Keyword/CurrNominal: self[#T#];
8282
// GEN_T_ASSOC_DOT: End completions
8383
func f3<T>(_: T) where T == #^FUNC_3^# {}
8484
func f3<T>(_: T) where T == T.#^FUNC_4^# {}
@@ -117,5 +117,4 @@ protocol P2 {
117117
// U_DOT: Begin completions
118118
// FIXME: Should complete Q from Assoc.
119119
// U_DOT-DAG: Keyword/None: Type[#Self.U.Type#];
120-
// U_DOT-DAG: Keyword/CurrNominal: self[#Self.U#];
121120
// U_DOT: End completions

0 commit comments

Comments
 (0)