-
Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathcomplete_after_self.swift
283 lines (242 loc) · 13.9 KB
/
complete_after_self.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// RUN: %empty-directory(%t)
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
//===---
//===--- Tests for code completion after 'self'.
//===---
class ThisBase1 {
var baseInstanceVar: Int
func baseFunc0() {}
func baseFunc1(_ a: Int) {}
subscript(i: Int) -> Double {
get {
return Double(i)
}
set(v) {
baseInstanceVar = i
}
}
class var baseStaticVar: Int = 12
class func baseStaticFunc0() {}
}
extension ThisBase1 {
var baseExtProp : Int {
get {
return 42
}
set(v) {}
}
func baseExtInstanceFunc0() {}
var baseExtStaticVar: Int
var baseExtStaticProp: Int {
get {
return 42
}
sel(v) {}
}
class func baseExtStaticFunc0() {}
struct BaseExtNestedStruct {}
class BaseExtNestedClass {}
enum BaseExtNestedEnum {
case BaseExtEnumX(Int)
}
typealias BaseExtNestedTypealias = Int
}
class ThisDerived1 : ThisBase1 {
var derivedInstanceVar: Int
func derivedFunc0() {}
subscript(i: Double) -> Int {
get {
return Int(i)
}
set(v) {
baseInstanceVar = Int(i)
}
}
subscript(s s: String) -> Int {
get {
return 0
}
set(v) {
}
}
class var derivedStaticVar: Int = 42
class func derivedStaticFunc0() {}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: .derivedInstanceVar[#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .derivedFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[Subscript]/CurrNominal: [{#(i): Double#}][#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[Subscript]/CurrNominal: [{#s: String#}][#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .test1()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .test2()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: .derivedExtProp[#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .derivedExtInstanceFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: .derivedExtStaticProp[#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/Super: .baseInstanceVar[#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseFunc1({#(a): Int#})[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[Subscript]/Super: [{#(i): Int#}][#Double#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/Super: .baseExtProp[#Int#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseExtInstanceFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_NO_DOT_1-DAG: Decl[InstanceVar]/Super: .baseExtStaticProp[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: derivedInstanceVar[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: derivedFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: test1()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: test2()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: derivedExtProp[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: derivedExtInstanceFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/CurrNominal: derivedExtStaticProp[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/Super: baseInstanceVar[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseFunc1({#(a): Int#})[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/Super: baseExtProp[#Int#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseExtInstanceFunc0()[#Void#]{{; name=.+$}}
// COMMON_SELF_DOT_1-DAG: Decl[InstanceVar]/Super: baseExtStaticProp[#Int#]{{; name=.+$}}
init() {
self#^CONSTRUCTOR_SELF_NO_DOT_1?check=CONSTRUCTOR_SELF_NO_DOT_1;check=COMMON_SELF_NO_DOT_1^#
// CONSTRUCTOR_SELF_NO_DOT_1: Begin completions, 21 items
// CONSTRUCTOR_SELF_NO_DOT_1-NOT: Decl[Constructor]
let d: ThisDerived1
d#^CONSTRUCTOR_NONSELF_NO_DOT_1?check=COMMON_SELF_NO_DOT_1;check=NO_INIT^#
// NO_INIT-NOT: init()
}
init(a: Int) {
self.#^CONSTRUCTOR_SELF_DOT_1?check=CONSTRUCTOR_SELF_DOT_1;check=COMMON_SELF_DOT_1^#
// CONSTRUCTOR_SELF_DOT_1: Begin completions, 16 items
// CONSTRUCTOR_SELF_DOT_1-NOT: Decl[Constructor]
let d: ThisDerived1
d.#^CONSTRUCTOR_NONSELF_DOT_1?check=COMMON_SELF_DOT_1;check=NO_INIT^#
}
convenience init(conv: Int) {
self.#^CONVENIENCE_SELF_DOT_1?check=CONVENIENCE_SELF_DOT_1;check=COMMON_SELF_DOT_1^#
// CONVENIENCE_SELF_DOT_1: Begin completions, 20 items
// CONVENIENCE_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#ThisDerived1#]; name=init()
// CONVENIENCE_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ThisDerived1#]; name=init(a:)
// CONVENIENCE_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#conv: Int#})[#ThisDerived1#]; name=init(conv:)
}
deinit {
self#^DESTRUCTOR_SELF_NO_DOT_1?check=DESTRUCTOR_SELF_NO_DOT_1;check=COMMON_SELF_NO_DOT_1;check=NO_INIT^#
// DESTRUCTOR_SELF_NO_DOT_1: Begin completions, 21 items
self.#^DESTRUCTOR_SELF_DOT_1?check=DESTRUCTOR_SELF_DOT_1;check=COMMON_SELF_DOT_1;check=NO_INIT^#
// DESTRUCTOR_SELF_DOT_1: Begin completions, 16 items
}
func test1() {
self#^FUNC_SELF_NO_DOT_1?check=FUNC_SELF_NO_DOT_1;check=COMMON_SELF_NO_DOT_1;check=NO_INIT^#
// FUNC_SELF_NO_DOT_1: Begin completions, 21 items
}
func test2() {
self.#^FUNC_SELF_DOT_1?check=FUNC_SELF_DOT_1;check=COMMON_SELF_DOT_1;check=NO_INIT^#
// FUNC_SELF_DOT_1: Begin completions, 16 items
}
class func staticTest1() {
self#^FUNC_STATIC_SELF_NO_DOT_1^#
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .derivedFunc0({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticVar]/CurrNominal: .derivedStaticVar[#Int#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: .derivedStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init()[#ThisDerived1#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init({#a: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init({#conv: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .test1({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .test2({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: .staticTest1()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: .staticTest2()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: .derivedExtInstanceFunc0({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: .derivedExtStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Struct]/CurrNominal: .DerivedExtNestedStruct[#DerivedExtNestedStruct#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Class]/CurrNominal: .DerivedExtNestedClass[#DerivedExtNestedClass#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Enum]/CurrNominal: .DerivedExtNestedEnum[#DerivedExtNestedEnum#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[TypeAlias]/CurrNominal: .DerivedExtNestedTypealias[#Int#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Constructor]/CurrNominal: .init({#someExtensionArg: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseFunc0({#(self): ThisBase1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseFunc1({#(self): ThisBase1#})[#(Int) -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticVar]/Super: .baseStaticVar[#Int#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/Super: .baseStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[InstanceMethod]/Super: .baseExtInstanceFunc0({#(self): ThisBase1#})[#() -> Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[StaticMethod]/Super: .baseExtStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Struct]/Super: .BaseExtNestedStruct[#ThisBase1.BaseExtNestedStruct#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Class]/Super: .BaseExtNestedClass[#ThisBase1.BaseExtNestedClass#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[Enum]/Super: .BaseExtNestedEnum[#ThisBase1.BaseExtNestedEnum#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Decl[TypeAlias]/Super: .BaseExtNestedTypealias[#Int#]
// FUNC_STATIC_SELF_NO_DOT_1-DAG: Keyword[self]/CurrNominal: .self[#ThisDerived1.Type#]; name=self
}
class func staticTest2() {
self.#^FUNC_STATIC_SELF_DOT_1^#
// FUNC_STATIC_SELF_DOT_1: Begin completions, 28 items
// FUNC_STATIC_SELF_DOT_1-DAG: Keyword[self]/CurrNominal: self[#ThisDerived1.Type#]; name=self
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: derivedFunc0({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticVar]/CurrNominal: derivedStaticVar[#Int#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: derivedStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#ThisDerived1#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#conv: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: test1({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: test2({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: staticTest1()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: staticTest2()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: derivedExtInstanceFunc0({#(self): ThisDerived1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/CurrNominal: derivedExtStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Struct]/CurrNominal: DerivedExtNestedStruct[#DerivedExtNestedStruct#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Class]/CurrNominal: DerivedExtNestedClass[#DerivedExtNestedClass#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Enum]/CurrNominal: DerivedExtNestedEnum[#DerivedExtNestedEnum#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[TypeAlias]/CurrNominal: DerivedExtNestedTypealias[#Int#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#someExtensionArg: Int#})[#ThisDerived1#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseFunc0({#(self): ThisBase1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseFunc1({#(self): ThisBase1#})[#(Int) -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticVar]/Super: baseStaticVar[#Int#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/Super: baseStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[InstanceMethod]/Super: baseExtInstanceFunc0({#(self): ThisBase1#})[#() -> Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[StaticMethod]/Super: baseExtStaticFunc0()[#Void#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Struct]/Super: BaseExtNestedStruct[#ThisBase1.BaseExtNestedStruct#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Class]/Super: BaseExtNestedClass[#ThisBase1.BaseExtNestedClass#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[Enum]/Super: BaseExtNestedEnum[#ThisBase1.BaseExtNestedEnum#]
// FUNC_STATIC_SELF_DOT_1-DAG: Decl[TypeAlias]/Super: BaseExtNestedTypealias[#Int#]
}
}
class func staticTest3() {
self(#^STATIC_SELF_PAREN^#
// STATIC_SELF_PAREN-NOT: Decl[Constructor]
}
extension ThisDerived1 {
var derivedExtProp : Int {
get {
return 42
}
set(v) {}
}
func derivedExtInstanceFunc0() {}
var derivedExtStaticVar: Int
var derivedExtStaticProp: Int {
get {
return 42
}
set(v) {}
}
class func derivedExtStaticFunc0() {}
struct DerivedExtNestedStruct {}
class DerivedExtNestedClass {}
enum DerivedExtNestedEnum {
case DerivedExtEnumX(Int)
}
typealias DerivedExtNestedTypealias = Int
convenience init(someExtensionArg: Int) {
self.#^EXTENSION_CONSTRUCTOR_SELF_DOT_1?check=COMMON_SELF_DOT_1;check=EXTENSION_CONSTRUCTOR_SELF_DOT_1^#
// EXTENSION_CONSTRUCTOR_SELF_DOT_1: Begin completions, 20 items
// EXTENSION_CONSTRUCTOR_SELF_DOT_1: Decl[Constructor]/CurrNominal: init()[#ThisDerived1#]; name=init()
// EXTENSION_CONSTRUCTOR_SELF_DOT_1: Decl[Constructor]/CurrNominal: init({#a: Int#})[#ThisDerived1#]; name=init(a:)
// EXTENSION_CONSTRUCTOR_SELF_DOT_1: Decl[Constructor]/CurrNominal: init({#someExtensionArg: Int#})[#ThisDerived1#]; name=init(someExtensionArg:)
}
}
struct S1 {
init() {}
init(x: Int) {
self.#^STRUCT_CONSTRUCTOR_SELF_DOT_1^#
// STRUCT_CONSTRUCTOR_SELF_DOT_1: Begin completions, 4 items
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Keyword[self]/CurrNominal: self[#S1#]; name=self
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init()[#S1#]; name=init()
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[Constructor]/CurrNominal: init({#x: Int#})[#S1#]; name=init(x:)
// STRUCT_CONSTRUCTOR_SELF_DOT_1-DAG: Decl[InstanceMethod]/CurrNominal: f()[#Void#]; name=f()
let s: S1
s.#^STRUCT_CONSTRUCTOR_NONSELF_DOT_1?check=NO_INIT^#
}
func f() {
self.#^STRUCT_FUNC_SELF_DOT_1?check=NO_INIT^#
}
}