@@ -7,20 +7,32 @@ protocol P1 {
7
7
class Base < T> : P1 {
8
8
typealias DependentClass = T
9
9
10
+ required init ( classInit: ( ) ) { }
11
+
10
12
func classSelfReturn( ) -> Self { }
11
13
}
12
14
13
15
protocol P2 {
14
16
typealias FullyConcrete = Int
15
17
typealias DependentProtocol = Self
16
18
19
+ init ( protocolInit: ( ) )
20
+
17
21
func protocolSelfReturn( ) -> Self
18
22
}
19
23
20
24
typealias BaseAndP2 < T> = Base < T > & P2
21
25
typealias BaseIntAndP2 = BaseAndP2 < Int >
22
26
23
27
class Derived : Base < Int > , P2 {
28
+ required init ( protocolInit: ( ) ) {
29
+ super. init ( classInit: ( ) )
30
+ }
31
+
32
+ required init ( classInit: ( ) ) {
33
+ super. init ( classInit: ( ) )
34
+ }
35
+
24
36
func protocolSelfReturn( ) -> Self { }
25
37
}
26
38
@@ -147,6 +159,14 @@ func conformsToBaseIntAndP2WithWhereClause<T>(_: T) where T : Base<Int> & P2 {}
147
159
// expected-note@-1 2 {{in call to function 'conformsToBaseIntAndP2WithWhereClause'}}
148
160
149
161
class FakeDerived : Base < String > , P2 {
162
+ required init ( classInit: ( ) ) {
163
+ super. init ( classInit: ( ) )
164
+ }
165
+
166
+ required init ( protocolInit: ( ) ) {
167
+ super. init ( classInit: ( ) )
168
+ }
169
+
150
170
func protocolSelfReturn( ) -> Self { return self }
151
171
}
152
172
@@ -177,6 +197,16 @@ func metatypeSubtyping(
177
197
let _: P2 . Type = derivedAndAnyObject
178
198
let _: ( P2 & AnyObject ) . Type = derived
179
199
let _: ( P2 & AnyObject ) . Type = derivedAndAnyObject
200
+
201
+ // Initializers
202
+ let _: Base < Int > & P2 = baseIntAndP2. init ( classInit: ( ) )
203
+ let _: Base < Int > & P2 = baseIntAndP2. init ( protocolInit: ( ) )
204
+ let _: Base < Int > & P2 & AnyObject = baseIntAndP2AndAnyObject. init ( classInit: ( ) )
205
+ let _: Base < Int > & P2 & AnyObject = baseIntAndP2AndAnyObject. init ( protocolInit: ( ) )
206
+ let _: Derived = derived. init ( classInit: ( ) )
207
+ let _: Derived = derived. init ( protocolInit: ( ) )
208
+ let _: Derived & AnyObject = derivedAndAnyObject. init ( classInit: ( ) )
209
+ let _: Derived & AnyObject = derivedAndAnyObject. init ( protocolInit: ( ) )
180
210
}
181
211
182
212
// There's a code path in CSApply that's hard to hit.
@@ -270,13 +300,30 @@ class ClassConformsToClassProtocolGood2 : Derived, ProtoRefinesClass {}
270
300
271
301
// Subclass existentials inside inheritance clauses
272
302
class CompositionInClassInheritanceClauseAlias : BaseIntAndP2 {
303
+ required init ( classInit: ( ) ) {
304
+ super. init ( classInit: ( ) ) // FIXME: expected-error {{}}
305
+ }
306
+
307
+ required init ( protocolInit: ( ) ) {
308
+ super. init ( classInit: ( ) ) // FIXME: expected-error {{}}
309
+ }
310
+
273
311
func protocolSelfReturn( ) -> Self { return self }
274
312
func asBase( ) -> Base < Int > { return self }
275
313
// FIXME expected-error@-1 {{}}
276
314
}
277
315
278
316
class CompositionInClassInheritanceClauseDirect : Base < Int > & P2 {
279
317
// expected-error@-1 {{protocol-constrained type is neither allowed nor needed here}}
318
+
319
+ required init ( classInit: ( ) ) {
320
+ super. init ( classInit: ( ) )
321
+ }
322
+
323
+ required init ( protocolInit: ( ) ) {
324
+ super. init ( classInit: ( ) )
325
+ }
326
+
280
327
func protocolSelfReturn( ) -> Self { return self }
281
328
func asBase( ) -> Base < Int > { return self }
282
329
}
0 commit comments