1
1
// RUN: %target-swift-ide-test -reconstruct-type -source-filename %s | %FileCheck %s -implicit-check-not="FAILURE"
2
2
3
+ // This test doesn't test a whole lot now that the more general (but buggy)
4
+ // getDeclFromMangledSymbolName() has been replaced with getTypeDeclForMangling().
5
+
6
+ // However we're still printing and reconstructing types for all the expressions
7
+ // we see here, even though there are no check lines.
8
+
9
+ // More comprehensive tests for getType{,Decl}ForMangling() are found in
10
+ // test/TypeDecoder/.
11
+
3
12
struct Mystruct1 {
4
13
// CHECK: decl: struct Mystruct1
5
14
func s1f1( ) -> Int { return 0 }
6
- // CHECK: decl: func s1f1() -> Int
7
15
var intField = 3
8
- // CHECK: decl: @_hasInitialValue var intField: Int
9
- // CHECK: decl: init(intField: Int)
10
- // CHECK: decl: init()
11
16
}
12
17
struct MyStruct2 {
13
18
// CHECK: decl: struct MyStruct2
14
19
init ( ) { }
15
- // CHECK: decl: init()
16
20
init ( x: Int ) { }
17
- // CHECK: decl: init(x: Int)
18
21
init ( x: Int , y: Int ) { }
19
- // CHECK: decl: init(x: Int, y: Int)
20
22
}
21
23
22
24
class Myclass1 {
23
25
// CHECK: decl: class Myclass1
24
26
var intField = 4
25
- // CHECK: decl: @_hasInitialValue var intField: Int
26
- // CHECK: decl: init()
27
27
}
28
28
29
29
func f1( ) {
30
- // CHECK: decl: func f1()
31
30
var s1ins = Mystruct1 ( ) // Implicit ctor
32
- // CHECK: decl: @_hasInitialValue var s1ins: Mystruct1
33
31
_ = Mystruct1 ( intField: 1 ) // Implicit ctor
34
32
35
33
s1ins. intField = 34
36
34
// CHECK: type: Mystruct1
37
35
// CHECK: type: Int
38
36
39
37
var c1ins = Myclass1 ( )
40
- // CHECK: decl: @_hasInitialValue var c1ins: Myclass1
41
38
// CHECK: type: Myclass1
42
39
43
40
c1ins. intField = 3
@@ -48,66 +45,49 @@ func f1() {
48
45
// CHECK: type: (Mystruct1) -> () -> Int
49
46
50
47
if let ifletf1 = Int ? ( 1 ) {
51
- // FIXME: lookup incorrect for if let binding.
52
- // CHECK: decl: struct Int : {{.*}} for 'ifletf1' usr=s:14swift_ide_test2f1yyF7ifletf1L_Siv
53
48
}
54
49
}
55
50
56
51
class Myclass2 {
57
52
// CHECK: decl: class Myclass2
58
53
func f1( ) {
59
- // CHECK: decl: func f1()
60
54
61
55
var arr1 = [ 1 , 2 ]
62
- // CHECK: decl: @_hasInitialValue var arr1: [Int]
63
56
// CHECK: type: [Int]
64
57
65
58
arr1. append ( 1 )
66
- // FIXME: missing append()
67
- // CHECK: dref: FAILURE for 'append' usr=s:Sa6appendyyxnF
68
59
// CHECK: type: (inout Array<Int>) -> (__owned Int) -> ()
69
60
70
61
var arr2 : [ Mystruct1 ]
71
- // CHECK: decl: var arr2: [Mystruct1]
72
62
// CHECK: type: [Mystruct1]
73
63
74
64
arr2. append ( Mystruct1 ( ) )
75
65
// CHECK: type: (inout Array<Mystruct1>) -> (__owned Mystruct1) -> ()
76
66
77
67
var arr3 : [ Myclass1 ]
78
- // CHECK: decl: var arr3: [Myclass1]
79
68
// CHECK: type: [Myclass1]
80
69
81
70
arr3. append ( Myclass1 ( ) )
82
71
// CHECK: type: (inout Array<Myclass1>) -> (__owned Myclass1) -> ()
83
72
84
73
_ = Myclass2 . init ( )
85
- // CHECK: dref: init()
86
74
}
87
75
}
88
76
89
77
// CHECK: decl: enum MyEnum
90
78
enum MyEnum {
91
- // FIXME
92
- // CHECK: decl: for 'ravioli'
93
79
case ravioli
94
- // CHECK: decl: for 'pasta'
95
80
case pasta
96
81
97
- // CHECK: decl: func method() -> Int
98
82
func method( ) -> Int { return 0 }
99
83
100
- // CHECK: decl: func compare(_ other: MyEnum) -> Int
101
84
func compare( _ other: MyEnum ) -> Int {
102
- // CHECK: decl: let other: MyEnum
103
85
return 0
104
86
}
105
87
106
- // CHECK: decl: mutating func mutatingMethod()
107
88
mutating func mutatingMethod( ) { }
108
89
}
109
90
110
- // CHECK: decl: func f2()
111
91
func f2( ) {
112
92
// CHECK: type: (MyEnum.Type) -> MyEnum
113
93
var e = MyEnum . pasta
@@ -122,18 +102,10 @@ func f2() {
122
102
123
103
struct MyGenStruct1 < T, U: ExpressibleByStringLiteral , V: Sequence > {
124
104
// CHECK: decl: struct MyGenStruct1<T, U, V> where U : ExpressibleByStringLiteral, V : Sequence
125
- // FIXME: why are these references to the base type?
126
- // FIXME: TypeReconstruction should support Node::Kind::GenericTypeParamDecl ('fp')
127
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test12MyGenStruct1V1Txmfp
128
- // CHECK: decl: FAILURE for 'U' usr=s:14swift_ide_test12MyGenStruct1V1Uq_mfp
129
- // CHECK: decl: FAILURE for 'V' usr=s:14swift_ide_test12MyGenStruct1V1Vq0_mfp
130
105
131
106
let x : T
132
- // CHECK: decl: let x: T
133
107
let y : U
134
- // CHECK: decl: let y: U
135
108
let z : V
136
- // CHECK: decl: let z: V
137
109
138
110
func test000( ) {
139
111
_ = x
@@ -144,22 +116,17 @@ struct MyGenStruct1<T, U: ExpressibleByStringLiteral, V: Sequence> {
144
116
// CHECK: type: V
145
117
}
146
118
147
- // CHECK: decl: func takesT(_ t: T)
148
119
func takesT( _ t: T ) {
149
- // CHECK: decl: let t: T
150
120
}
151
121
}
152
122
153
123
let genstruct1 = MyGenStruct1 < Int , String , [ Float ] > ( x: 1 , y: " " , z: [ 1.0 ] )
154
- // CHECK: decl: @_hasInitialValue let genstruct1: MyGenStruct1<Int, String, [Float]>
155
124
156
125
func test001( ) {
157
- // CHECK: decl: func test001()
158
126
_ = genstruct1
159
127
// CHECK: type: MyGenStruct1<Int, String, [Float]>
160
128
161
129
var genstruct2 : MyGenStruct1 < Int , String , [ Int : Int ] >
162
- // CHECK: decl: var genstruct2: MyGenStruct1<Int, String, [Int : Int]>
163
130
_ = genstruct2
164
131
// CHECK: type: MyGenStruct1<Int, String, [Int : Int]>
165
132
_ = genstruct2. x
@@ -175,41 +142,30 @@ func test001() {
175
142
// CHECK: decl: protocol P1
176
143
protocol P1 { }
177
144
178
- // CHECK: decl: func foo1(p: P1)
179
145
func foo1( p: P1 ) {
180
- // CHECK: decl: let p: P1
181
146
// CHECK: type: (P1) -> ()
182
147
foo1 ( p: p)
183
148
}
184
149
185
150
// CHECK: decl: protocol P2
186
151
protocol P2 { }
187
152
188
- // CHECK: decl: func foo2(p: P1 & P2)
189
153
func foo2( p: P1 & P2 ) {
190
- // CHECK: decl: let p: P1 & P2
191
154
foo2 ( p: p)
192
155
}
193
156
194
- // CHECK: func foo3(p: P1 & AnyObject)
195
157
func foo3( p: P1 & AnyObject ) {
196
- // CHECK: decl: let p: P1 & AnyObject
197
158
foo3 ( p: p)
198
159
}
199
160
200
- // CHECK: func foo4(p: Myclass1 & P1 & P2)
201
161
func foo4( p: P1 & P2 & Myclass1 ) {
202
- // CHECK: decl: let p: Myclass1 & P1 & P2
203
162
foo4 ( p: p)
204
163
}
205
164
206
165
func genericFunction< T : AnyObject > ( t: T ) {
207
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test15genericFunction1tyx_tRlzClF1TL_xmfp
208
166
genericFunction ( t: t)
209
167
}
210
168
211
- // CHECK: decl: func takesInOut(fn: (inout Int) -> ())
212
- // CHECK: decl: let fn: (inout Int) -> () for 'fn'
213
169
func takesInOut( fn: ( inout Int ) -> ( ) ) { }
214
170
215
171
struct Outer {
@@ -218,36 +174,30 @@ struct Outer {
218
174
}
219
175
220
176
struct GenericInner < T> {
221
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test5OuterV12GenericInnerV1Txmfp
222
177
let t : T
223
178
}
224
179
}
225
180
226
181
struct GenericOuter < T> {
227
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test12GenericOuterV1Txmfp
228
182
struct Inner {
229
183
let t : T
230
184
let x : Int
231
185
}
232
186
233
187
struct GenericInner < U> {
234
- // CHECK: decl: FAILURE for 'U' usr=s:14swift_ide_test12GenericOuterV0D5InnerV1Uqd__mfp
235
188
let t : T
236
189
let u : U
237
190
}
238
191
}
239
192
240
- // CHECK: decl: func takesGeneric(_ t: Outer.GenericInner<Int>)
241
193
func takesGeneric( _ t: Outer . GenericInner < Int > ) {
242
194
takesGeneric ( t)
243
195
}
244
196
245
- // CHECK: decl: func takesGeneric(_ t: GenericOuter<Int>.Inner)
246
197
func takesGeneric( _ t: GenericOuter < Int > . Inner ) {
247
198
takesGeneric ( t)
248
199
}
249
200
250
- // CHECK: decl: func takesGeneric(_ t: GenericOuter<Int>.GenericInner<String>)
251
201
func takesGeneric( _ t: GenericOuter < Int > . GenericInner < String > ) {
252
202
takesGeneric ( t)
253
203
}
@@ -257,24 +207,14 @@ func hasLocalDecls() {
257
207
258
208
// CHECK: decl: struct LocalType for 'LocalType' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_V
259
209
struct LocalType {
260
- // CHECK: func localMethod() for 'localMethod' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_V11localMethodyyF
261
210
func localMethod( ) { }
262
211
263
- // CHECK: subscript(x: Int) -> Int { get set } for 'subscript' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_VyS2icip
264
212
subscript( x: Int ) -> Int { get { } set { } }
265
-
266
- // CHECK: decl: get for '' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_VyS2icig
267
- // CHECK: decl: set for '' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_VyS2icis
268
- // CHECK: decl: init() for '' usr=s:14swift_ide_test13hasLocalDeclsyyF0E4TypeL_VADycfc
269
-
270
213
}
271
214
272
215
// CHECK: decl: class LocalClass for 'LocalClass' usr=s:14swift_ide_test13hasLocalDeclsyyF0E5ClassL_C
273
216
class LocalClass {
274
- // CHECK: decl: {{(@objc )?}}deinit for 'deinit' usr=s:14swift_ide_test13hasLocalDeclsyyF0E5ClassL_Cfd
275
217
deinit { }
276
-
277
- // CHECK: decl: init() for '' usr=s:14swift_ide_test13hasLocalDeclsyyF0E5ClassL_CADycfc
278
218
}
279
219
280
220
// CHECK: decl: typealias LocalAlias = LocalType for 'LocalAlias' usr=s:14swift_ide_test13hasLocalDeclsyyF0E5AliasL_a
@@ -283,48 +223,27 @@ func hasLocalDecls() {
283
223
284
224
fileprivate struct VeryPrivateData { }
285
225
286
- // CHECK: decl: fileprivate func privateFunction(_ d: VeryPrivateData) for 'privateFunction'
287
226
fileprivate func privateFunction( _ d: VeryPrivateData ) { }
288
227
289
228
struct HasSubscript {
290
- // CHECK: decl: subscript(t: Int) -> Int { get set }
291
229
subscript( _ t: Int ) -> Int {
292
- // CHECK: decl: get for '' usr=s:14swift_ide_test12HasSubscriptVyS2icig
293
230
get {
294
231
return t
295
232
}
296
- // CHECK: decl: set for '' usr=s:14swift_ide_test12HasSubscriptVyS2icis
297
233
set { }
298
234
}
299
235
}
300
236
301
- // FIXME
302
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test19HasGenericSubscriptV1Txmfp
303
237
struct HasGenericSubscript < T> {
304
- // CHECK: subscript<U>(t: T) -> U { get set } for 'subscript' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xcluip
305
- // FIXME
306
- // CHECK: decl: FAILURE for 'U'
307
- // FIXME
308
- // CHECK: decl: FAILURE for 't'
309
238
subscript< U> ( _ t: T ) -> U {
310
-
311
- // CHECK: decl: get for '' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xcluig
312
- // FIXME
313
- // CHECK: dref: FAILURE for 't'
314
239
get {
315
240
return t as! U
316
241
}
317
-
318
- // CHECK: decl: set for '' usr=s:14swift_ide_test19HasGenericSubscriptVyqd__xcluis
319
242
set { }
320
243
}
321
244
}
322
245
323
246
private
324
- // CHECK: decl: private func patatino<T>(_ vers1: T, _ vers2: T) -> Bool where T : Comparable for
325
247
func patatino< T: Comparable > ( _ vers1: T , _ vers2: T ) -> Bool {
326
- // CHECK: decl: FAILURE for 'T' usr=s:14swift_ide_test8patatino33_D7B956AE2D93947DFA67A1ECF93EF238LLySbx_xtSLRzlF1TL_xmfp decl
327
- // CHECK: decl: let vers1: T for 'vers1' usr=s:14swift_ide_test8patatino33_D7B956AE2D93947DFA67A1ECF93EF238LLySbx_xtSLRzlF5vers1L_xvp
328
- // CHECK: decl: let vers2: T for 'vers2' usr=s:14swift_ide_test8patatino33_D7B956AE2D93947DFA67A1ECF93EF238LLySbx_xtSLRzlF5vers2L_xvp
329
248
return vers1 < vers2;
330
249
}
0 commit comments