-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathcomplete_init.swift
148 lines (123 loc) · 5.45 KB
/
complete_init.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// RUN: sed -n -e '1,/NO_ERRORS_UP_TO_HERE$/ p' %s > %t_no_errors.swift
// RUN: %target-swift-frontend -typecheck -verify %t_no_errors.swift
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=TOP_LEVEL_0 > %t
// RUN: %FileCheck %s -check-prefix=TOP_LEVEL_0 < %t
// RUN: %FileCheck %s -check-prefix=NEGATIVE_TOP_LEVEL_0 < %t
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=TOP_LEVEL_1 > %t.generic
// RUN: %FileCheck %s -check-prefix=TOP_LEVEL_0 < %t.generic
// RUN: %FileCheck %s -check-prefix=GENERIC_PARAM_0 < %t.generic
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=K_QUALIFIED_0 | %FileCheck %s -check-prefix=K_QUALIFIED_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=L_QUALIFIED_0 | %FileCheck %s -check-prefix=L_QUALIFIED_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=L_QUALIFIED_0 | %FileCheck %s -check-prefix=NEGATIVE_L_QUALIFIED_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=INSIDE_L_0 | %FileCheck %s -check-prefix=INSIDE_L_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-complete-inits-in-postfix-expr -code-completion-token=INSIDE_M_0 | %FileCheck %s -check-prefix=INSIDE_M_0
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=ALIAS_CONSTRUCTOR_0 | %FileCheck %s -check-prefix=ALIAS_CONSTRUCTOR_0
struct A {
// implicit init()
}
struct B {
let x: A, y: A, z: A
// implicit init(x:,y:,z:)
}
struct C {
init() {}
init(x: A) {}
init(y: A=A()) {}
}
class D {
// implicit init()
}
class E {
init(x: A) {}
}
class F : E {
// inherited init(x: A)
convenience init() {}
}
protocol G {
init(x: A)
}
struct H : G {
init(x: A) {}
}
protocol I : G {
init(y: A)
}
typealias J = A
struct K {
typealias X = A
struct Y {}
}
struct L<X: G> {
typealias Y = X
}
// NO_ERRORS_UP_TO_HERE
func testTopLevel() {
#^TOP_LEVEL_0^#
}
// TOP_LEVEL_0: Begin completions
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: A()[#A#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: B({#x: A#}, {#y: A#}, {#z: A#})[#B#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: C()[#C#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: C({#x: A#})[#C#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: C({#y: A#})[#C#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: D()[#D#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: E({#x: A#})[#E#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: F({#x: A#})[#F#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: F()[#F#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: G({#x: A#})[#G#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: H({#x: A#})[#H#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: I({#x: A#})[#I#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: I({#y: A#})[#I#]{{; name=.+}}
// TOP_LEVEL_0-DAG: Decl[Constructor]/CurrModule: J()[#A#]{{; name=.+}}
// TOP_LEVEL_0: End completions
// NEGATIVE_TOP_LEVEL_0-NOT: Decl[Constructor]/CurrModule: E()
func testQualified0() {
K.#^K_QUALIFIED_0^#
}
// K_QUALIFIED_0: Begin completions
// K_QUALIFIED_0-DAG: Decl[Constructor]/CurrNominal: X()[#A#]{{; name=.+}}
// K_QUALIFIED_0-DAG: Decl[Constructor]/CurrNominal: Y()[#K.Y#]{{; name=.+}}
// K_QUALIFIED_0: End completions
func testQualified1() {
L.#^L_QUALIFIED_0^#
}
// L_QUALIFIED_0: Begin completions
// L_QUALIFIED_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}}
// L_QUALIFIED_0: End completions
// NEGATIVE_L_QUALIFIED_0-NOT: X({#x: A#})
func testGenericParam<T: I, U: G>() {
#^TOP_LEVEL_1^#
}
// GENERIC_PARAM_0: Begin completions
// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#x: A#})[#I#]{{; name=.+}}
// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: T({#y: A#})[#I#]{{; name=.+}}
// GENERIC_PARAM_0-DAG: Decl[Constructor]/Local: U({#x: A#})[#G#]{{; name=.+}}
// GENERIC_PARAM_0-NOT: Decl[Constructor]/Local: U({#y
// GENERIC_PARAM_0: End completions
extension L {
func test() {
#^INSIDE_L_0^#
}
}
// INSIDE_L_0: Begin completions
// INSIDE_L_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}}
// FIXME: <rdar://problem/20530021> Code complete generic parameters in extensions
// 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
struct M<X: G> {
typealias Y = X
func test() {
#^INSIDE_M_0^#
}
}
// INSIDE_M_0: Begin completions
// INSIDE_M_0-DAG: Decl[Constructor]/CurrNominal: Y({#x: A#})[#G#]{{; name=.+}}
// INSIDE_M_0-DAG: Decl[Constructor]/Local: X({#x: A#})[#G#]{{; name=.+}}
// INSIDE_M_0: End completions
typealias CAlias = C
var CAliasInstance = CAlias(#^ALIAS_CONSTRUCTOR_0^#
// rdar://18586415
// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal: ['(']{#x: A#}[')'][#CAlias#];
// ALIAS_CONSTRUCTOR_0: Decl[Constructor]/CurrNominal: ['(']{#y: A#}[')'][#CAlias#];