forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcircularity.swift
283 lines (247 loc) · 7.64 KB
/
circularity.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
// Please keep this file in alphabetical order!
// REQUIRES: objc_interop
// RUN: %empty-directory(%t)
// FIXME: BEGIN -enable-source-import hackaround
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/CoreGraphics.swift
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -emit-module -o %t %S/../Inputs/clang-importer-sdk/swift-modules/Foundation.swift
// FIXME: END -enable-source-import hackaround
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -import-objc-header %S/Inputs/circularity.h -emit-module -o %t %s
// RUN: %target-swift-frontend(mock-sdk: -sdk %S/../Inputs/clang-importer-sdk -I %t) -import-objc-header %S/Inputs/circularity.h -parse-as-library %t/circularity.swiftmodule -typecheck -emit-objc-header-path %t/circularity.h
// RUN: %FileCheck %s < %t/circularity.h
// RUN: %check-in-clang %t/circularity.h
// RUN: %check-in-clang -fno-modules -Qunused-arguments %t/circularity.h
import Foundation
// CHECK-LABEL: @interface A1 : ProtoImpl
class A1: ProtoImpl {
// CHECK: // 'test(_:)' below
func test(_: NeedsProto<A2>) {}
} // CHECK: @end
// CHECK-LABEL: @interface A2 : ProtoImpl
class A2: ProtoImpl {
// CHECK: - (void)test:
func test(_: NeedsProto<A1>) {}
} // CHECK: @end
// CHECK-LABEL: @interface B1 : ProtoImpl
class B1: ProtoImpl {
// CHECK: // 'test(_:)' below
func test(_: NeedsProto<B2>) {}
} // CHECK: @end
// CHECK-LABEL: @interface B2 : ProtoImpl
class B2: ProtoImpl {
} // CHECK: @end
// CHECK-LABEL: @interface C1 : ProtoImpl
class C1: ProtoImpl {
// CHECK: // 'test(_:)' below
func test(_: NeedsProto<C2>) {}
} // CHECK: @end
// CHECK-LABEL: @protocol C2 <Proto>
@objc protocol C2: Proto {
} // CHECK: @end
// CHECK-LABEL: @interface D1 : ProtoImpl
class D1: ProtoImpl {
// CHECK: // 'test(_:)' below
func test(_: NeedsProto<D2>) {}
} // CHECK: @end
// CHECK-LABEL: @protocol D2 <Proto>
@objc protocol D2: Proto {
// CHECK: - (void)test:
func test(_: NeedsProto<D1>)
} // CHECK: @end
// CHECK-LABEL: @interface D4 : ProtoImpl
// CHECK: // 'test(_:)' below
// CHECK: @end
// CHECK-LABEL: @protocol D3 <Proto>
@objc protocol D3: Proto {
// CHECK: - (void)test:
func test(_: NeedsProto<D4>)
} // CHECK: @end
// Moved ahead.
class D4: ProtoImpl {
func test(_: NeedsProto<D3>) {}
}
// CHECK-LABEL: @interface E2 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol E1 <Proto>
@objc protocol E1: Proto {
// CHECK: - (void)test:
func test(_: NeedsProto<E2>)
} // CHECK: @end
// Moved ahead.
class E2: ProtoImpl {}
// CHECK-LABEL: @interface F1 : ProtoImpl
class F1: ProtoImpl {
} // CHECK: @end
// CHECK-LABEL @interface F2 : ProtoImpl
// CHECK: @end
// CHECK-LABEL @interface F1 (SWIFT_EXTENSION(circularity))
extension F1 {
// CHECK: - (void)test:
func test(_: NeedsProto<F2>) {}
} // CHECK: @end
// Moved ahead.
class F2: ProtoImpl {}
// CHECK-LABEL: @interface G1 : ProtoImpl
class G1: ProtoImpl {
} // CHECK: @end
// CHECK-LABEL @protocol G2 <Proto>
// CHECK: @end
// CHECK-LABEL @interface G1 (SWIFT_EXTENSION(circularity))
extension G1 {
// CHECK: - (void)test:
func test(_: NeedsProto<G2>) {}
} // CHECK: @end
// Moved ahead.
@objc protocol G2: Proto {}
// CHECK-LABEL: @interface H1 : ProtoImpl
class H1: ProtoImpl {
// CHECK: 'test(_:)' below
func test(_: NeedsProto<H2>) {}
// CHECK: 'anotherTest(_:)' below
func anotherTest(_: NeedsProto<H3>) {}
} // CHECK: @end
// CHECK-LABEL: @interface H2 : ProtoImpl
class H2: ProtoImpl {
// CHECK: // 'test(_:)' below
func test(_: NeedsProto<H3>) {}
// CHECK: - (void)anotherTest:
func anotherTest(_: NeedsProto<H1>) {}
} // CHECK: @end
// CHECK-LABEL: @interface H3 : ProtoImpl
class H3: ProtoImpl {
// CHECK: - (void)test:
func test(_: NeedsProto<H1>) {}
// CHECK: - (void)anotherTest:
func anotherTest(_: NeedsProto<H2>) {}
} // CHECK: @end
// CHECK-LABEL: @interface I1 : Parent
class I1 : Parent {
// CHECK: // 'test(_:)' below
func test(_: NeedsParent<I2>) {}
} // CHECK: @end
// CHECK-LABEL: @interface I2 : Parent
class I2 : Parent {
// CHECK: - (void)test:
func test(_: NeedsParent<I1>) {}
} // CHECK: @end
// CHECK-LABEL: @interface J1 : Parent
class J1 : Parent {
// CHECK: - (void)test:
func test(_: Unconstrained<J2>) {}
} // CHECK: @end
// CHECK-LABEL: @interface J2 : Parent
class J2 : Parent {
// CHECK: - (void)test:
func test(_: Unconstrained<J1>) {}
} // CHECK: @end
// CHECK-LABEL: @protocol K1 <Proto>
@objc protocol K1 : Proto {
// CHECK: - (void)test:
func test(_: Unconstrained<K2>)
} // CHECK: @end
// CHECK-LABEL: @protocol K2 <Proto>
@objc protocol K2 : Proto {
// CHECK: - (void)test:
func test(_: Unconstrained<K1>)
} // CHECK: @end
// CHECK-LABEL: @interface NA2 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol NA1
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface NA3 : NSObject <NA1>
// CHECK: @end
@objc protocol NA1 {
@objc optional func test(_: NeedsProto<NA2>)
}
class NA2: ProtoImpl {}
class NA3: NSObject, NA1 {}
// CHECK-LABEL: @interface NB1 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol NB2
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface NB3 : NSObject <NB2>
// CHECK: @end
class NB1: ProtoImpl {}
@objc protocol NB2 {
@objc optional func test(_: NeedsProto<NB1>)
}
class NB3: NSObject, NB2 {}
// CHECK-LABEL: @interface NC2 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol NC3
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface NC1 : NSObject <NC3>
// CHECK: @end
class NC1: NSObject, NC3 {}
class NC2: ProtoImpl {}
@objc protocol NC3 {
@objc optional func test(_: NeedsProto<NC2>)
}
// CHECK-LABEL: @interface ND3 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol ND2
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface ND1 : NSObject <ND2>
// CHECK: @end
class ND1: NSObject, ND2 {}
@objc protocol ND2 {
@objc optional func test(_: NeedsProto<ND3>)
}
class ND3: ProtoImpl {}
// CHECK-LABEL: @interface NE3 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol NE1
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface NE2 : NSObject <NE1>
// CHECK: @end
@objc protocol NE1 {
@objc optional func test(_: NeedsProto<NE3>)
}
class NE2: NSObject, NE1 {}
class NE3: ProtoImpl {}
// CHECK-LABEL: @interface NF2 : ProtoImpl
// CHECK: @end
// CHECK-LABEL: @protocol NF1
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface NF3 : NSObject <NF1>
// CHECK: @end
@objc protocol NF1 {
@objc optional func test(_: NeedsProto<NF2>)
}
class NF2: ProtoImpl {}
class NF3: NSObject, NF1 {}
// CHECK-LABEL: @interface ZZZ_EOF : NSObject
class ZZZ_EOF : NSObject {
} // CHECK: @end
// CHECK-LABEL: @interface A1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface B1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface C1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface D1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface D4 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface H1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK-NOT: @end
// CHECK: - (void)anotherTest:
// CHECK: @end
// CHECK-LABEL: @interface H2 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end
// CHECK-LABEL: @interface I1 (SWIFT_EXTENSION(circularity))
// CHECK: - (void)test:
// CHECK: @end