1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
3
+
4
+ protocol MyProto {
5
+ typealias Content = Int
6
+ }
7
+ func testSimpleInTypeCompletion( ) -> MyProto . #^SIMPLE_IN_TYPE_COMPLETION^# { }
8
+ // SIMPLE_IN_TYPE_COMPLETION: Begin completions, 3 items
9
+ // SIMPLE_IN_TYPE_COMPLETION-DAG: Decl[TypeAlias]/CurrNominal: Content[#Int#];
10
+ // SIMPLE_IN_TYPE_COMPLETION-DAG: Keyword/None: Protocol[#MyProto.Protocol#];
11
+ // SIMPLE_IN_TYPE_COMPLETION-DAG: Keyword/None: Type[#MyProto.Type#];
12
+ // SIMPLE_IN_TYPE_COMPLETION: End completions
13
+
14
+ func testUnconstrainedUnresolvedMember( ) {
15
+ let _: MyProto = . #^UNCONSTRAINED_UNRESOLVED_MEMBER^#
16
+ // UNCONSTRAINED_UNRESOLVED_MEMBER: Begin completions, 1 item
17
+ // UNCONSTRAINED_UNRESOLVED_MEMBER-DAG: Decl[TypeAlias]/CurrNominal: Content[#Int#];
18
+ // UNCONSTRAINED_UNRESOLVED_MEMBER: End completions
19
+ }
20
+
21
+ protocol MyOtherProto {
22
+ associatedtype MyAssocType
23
+ }
24
+ extension MyOtherProto where MyAssocType == String {
25
+ typealias Content = Int
26
+ }
27
+
28
+ // `Content` is actually accessible on `MyOtherProto` here, but that seems more like a bug of the language than a feature, so we don't want to promote it in code completion.
29
+ func testConstrainedInTypeCompletion( ) -> MyOtherProto . #^CONSTRAINED_IN_TYPE_COMPLETION^# { }
30
+ // CONSTRAINED_IN_TYPE_COMPLETION: Begin completions, 3 items
31
+ // CONSTRAINED_IN_TYPE_COMPLETION-DAG: Decl[AssociatedType]/CurrNominal: MyAssocType;
32
+ // CONSTRAINED_IN_TYPE_COMPLETION-DAG: Keyword/None: Protocol[#MyOtherProto.Protocol#];
33
+ // CONSTRAINED_IN_TYPE_COMPLETION-DAG: Keyword/None: Type[#MyOtherProto.Type#];
34
+ // CONSTRAINED_IN_TYPE_COMPLETION: End completions
35
+
36
+ func testConstrainedUnresolvedMember( ) {
37
+ let _: MyOtherProto = . #^CONSTRAINED_UNRESOLVED_MEMBER^#
38
+ // CONSTRAINED_UNRESOLVED_MEMBER: Begin completions, 1 item
39
+ // CONSTRAINED_UNRESOLVED_MEMBER-DAG: Decl[AssociatedType]/CurrNominal: MyAssocType;
40
+ // CONSTRAINED_UNRESOLVED_MEMBER: End completions
41
+ }
42
+
43
+ protocol ProtoWithGenericTypealias {
44
+ typealias Storage < T> = Array < T >
45
+ }
46
+ func testGenericInTypeCompletion( ) -> ProtoWithGenericTypealias . #^GENERIC_IN_TYPE_COMPLETION^# { }
47
+ // GENERIC_IN_TYPE_COMPLETION: Begin completions, 3 items
48
+ // GENERIC_IN_TYPE_COMPLETION-DAG: Decl[TypeAlias]/CurrNominal: Storage[#Array<T>#];
49
+ // GENERIC_IN_TYPE_COMPLETION-DAG: Keyword/None: Protocol[#ProtoWithGenericTypealias.Protocol#];
50
+ // GENERIC_IN_TYPE_COMPLETION-DAG: Keyword/None: Type[#ProtoWithGenericTypealias.Type#];
51
+ // GENERIC_IN_TYPE_COMPLETION: End completions
52
+
53
+ func testGenericUnresolvedMember( ) {
54
+ let _: ProtoWithGenericTypealias = . #^GENERIC_UNRESOLVED_MEMBER^#
55
+ // GENERIC_UNRESOLVED_MEMBER: Begin completions, 1 item
56
+ // GENERIC_UNRESOLVED_MEMBER-DAG: Decl[TypeAlias]/CurrNominal: Storage[#Array<T>#];
57
+ // GENERIC_UNRESOLVED_MEMBER: End completions
58
+ }
0 commit comments