@@ -155,6 +155,9 @@ func nongenericAnyIsPProtocol(type: Any.Type) -> Bool {
155
155
func nongenericAnyIsPAndAnyObjectType( type: Any . Type ) -> Bool {
156
156
return type is ( P & AnyObject ) . Type
157
157
}
158
+ func nongenericAnyIsPAndAnyObjectProtocol( type: Any . Type ) -> Bool {
159
+ return type is ( P & AnyObject ) . Protocol
160
+ }
158
161
func nongenericAnyIsPAndPCSubType( type: Any . Type ) -> Bool {
159
162
return type is ( P & PCSub ) . Type
160
163
}
@@ -178,6 +181,9 @@ func nongenericAnyAsConditionalPProtocol(type: Any.Type) -> Bool {
178
181
func nongenericAnyAsConditionalPAndAnyObjectType( type: Any . Type ) -> Bool {
179
182
return ( type as? ( P & AnyObject ) . Type) != nil
180
183
}
184
+ func nongenericAnyAsConditionalPAndAnyObjectProtocol( type: Any . Type ) -> Bool {
185
+ return ( type as? ( P & AnyObject ) . Protocol) != nil
186
+ }
181
187
func nongenericAnyAsConditionalPAndPCSubType( type: Any . Type ) -> Bool {
182
188
return ( type as? ( P & PCSub ) . Type) != nil
183
189
}
@@ -230,16 +236,16 @@ print(#line, PS() is P) // CHECK: [[@LINE]] true
230
236
// But that theory is not the one that Swift currently
231
237
// implements.
232
238
print ( #line, nongenericAnyIsPProtocol ( type: PS . self) ) // CHECK: [[@LINE]] false
233
- print ( #line, genericAnyIs ( type: PS . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
239
+ print ( #line, genericAnyIs ( type: PS . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
234
240
print ( #line, nongenericAnyIsPType ( type: PE . self) ) // CHECK: [[@LINE]] true
235
241
print ( #line, nongenericAnyIsPProtocol ( type: PE . self) ) // CHECK: [[@LINE]] false
236
- print ( #line, genericAnyIs ( type: PE . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
242
+ print ( #line, genericAnyIs ( type: PE . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
237
243
print ( #line, nongenericAnyIsPType ( type: PC . self) ) // CHECK: [[@LINE]] true
238
244
print ( #line, nongenericAnyIsPProtocol ( type: PC . self) ) // CHECK: [[@LINE]] false
239
- print ( #line, genericAnyIs ( type: PC . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
245
+ print ( #line, genericAnyIs ( type: PC . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
240
246
print ( #line, nongenericAnyIsPType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
241
247
print ( #line, nongenericAnyIsPProtocol ( type: PCSub . self) ) // CHECK: [[@LINE]] false
242
- print ( #line, genericAnyIs ( type: PCSub . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
248
+ print ( #line, genericAnyIs ( type: PCSub . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
243
249
244
250
// CHECK-LABEL: conditionally casting types to protocols with generics:
245
251
print ( #line, " conditionally casting types to protocols with generics: " )
@@ -248,16 +254,16 @@ print(#line, nongenericAnyAsConditionalPProtocol(type: P.self)) // CHECK: [[@LIN
248
254
print ( #line, genericAnyAsConditional ( type: P . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] true
249
255
print ( #line, nongenericAnyAsConditionalPType ( type: PS . self) ) // CHECK: [[@LINE]] true
250
256
print ( #line, nongenericAnyAsConditionalPProtocol ( type: PS . self) ) // CHECK: [[@LINE]] false
251
- print ( #line, genericAnyAsConditional ( type: PS . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
257
+ print ( #line, genericAnyAsConditional ( type: PS . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
252
258
print ( #line, nongenericAnyAsConditionalPType ( type: PE . self) ) // CHECK: [[@LINE]] true
253
259
print ( #line, nongenericAnyAsConditionalPProtocol ( type: PE . self) ) // CHECK: [[@LINE]] false
254
- print ( #line, genericAnyAsConditional ( type: PE . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
260
+ print ( #line, genericAnyAsConditional ( type: PE . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
255
261
print ( #line, nongenericAnyAsConditionalPType ( type: PC . self) ) // CHECK: [[@LINE]] true
256
262
print ( #line, nongenericAnyAsConditionalPProtocol ( type: PC . self) ) // CHECK: [[@LINE]] false
257
- print ( #line, genericAnyAsConditional ( type: PC . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
263
+ print ( #line, genericAnyAsConditional ( type: PC . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
258
264
print ( #line, nongenericAnyAsConditionalPType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
259
265
print ( #line, nongenericAnyAsConditionalPProtocol ( type: PCSub . self) ) // CHECK: [[@LINE]] false
260
- print ( #line, genericAnyAsConditional ( type: PCSub . self, to: P . self, expected: true ) ) // CHECK: [[@LINE]] false
266
+ print ( #line, genericAnyAsConditional ( type: PCSub . self, to: P . self, expected: false ) ) // CHECK: [[@LINE]] false
261
267
262
268
// CHECK-LABEL: unconditionally casting types to protocols with generics:
263
269
print ( #line, " unconditionally casting types to protocols with generics: " )
@@ -280,17 +286,20 @@ print(#line, genericAnyIs(type: PS.self, to: (P & AnyObject).self, expected: fal
280
286
print ( #line, nongenericAnyIsPAndAnyObjectType ( type: PE . self) ) // CHECK: [[@LINE]] false
281
287
print ( #line, genericAnyIs ( type: PE . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
282
288
print ( #line, nongenericAnyIsPAndAnyObjectType ( type: PC . self) ) // CHECK: [[@LINE]] true
283
- print ( #line, genericAnyIs ( type: PC . self, to: ( P & AnyObject) . self, expected: true ) ) // CHECK: [[@LINE]] false
289
+ print ( #line, nongenericAnyIsPAndAnyObjectProtocol ( type: PC . self) ) // CHECK: [[@LINE]] false
290
+ print ( #line, genericAnyIs ( type: PC . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
284
291
print ( #line, nongenericAnyIsPAndAnyObjectType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
285
- print ( #line, genericAnyIs ( type: PCSub . self, to: ( P & AnyObject) . self, expected: true ) ) // CHECK: [[@LINE]] false
292
+ print ( #line, nongenericAnyIsPAndAnyObjectProtocol ( type: PCSub . self) ) // CHECK: [[@LINE]] false
293
+ print ( #line, genericAnyIs ( type: PCSub . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
286
294
print ( #line, nongenericAnyAsConditionalPAndAnyObjectType ( type: PS . self) ) // CHECK: [[@LINE]] false
287
295
print ( #line, genericAnyAsConditional ( type: PS . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
288
296
print ( #line, nongenericAnyAsConditionalPAndAnyObjectType ( type: PE . self) ) // CHECK: [[@LINE]] false
289
297
print ( #line, genericAnyAsConditional ( type: PE . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
290
298
print ( #line, nongenericAnyAsConditionalPAndAnyObjectType ( type: PC . self) ) // CHECK: [[@LINE]] true
291
- print ( #line, genericAnyAsConditional ( type: PC . self, to: ( P & AnyObject) . self, expected: true ) ) // CHECK: [[@LINE]] false
299
+ print ( #line, nongenericAnyAsConditionalPAndAnyObjectProtocol ( type: PC . self) ) // CHECK: [[@LINE]] false
300
+ print ( #line, genericAnyAsConditional ( type: PC . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
292
301
print ( #line, nongenericAnyAsConditionalPAndAnyObjectType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
293
- print ( #line, genericAnyAsConditional ( type: PCSub . self, to: ( P & AnyObject) . self, expected: true ) ) // CHECK: [[@LINE]] false
302
+ print ( #line, genericAnyAsConditional ( type: PCSub . self, to: ( P & AnyObject) . self, expected: false ) ) // CHECK: [[@LINE]] false
294
303
295
304
// CHECK-LABEL: casting types to protocol & class existentials:
296
305
print ( #line, " casting types to protocol & class existentials: " )
@@ -301,15 +310,15 @@ print(#line, genericAnyIs(type: PE.self, to: (P & PCSub).self, expected: false))
301
310
//print(#line, nongenericAnyIsPAndPCSubType(type: PC.self)) // CHECK-SR-11565: [[@LINE]] false -- FIXME: reenable this when SR-11565 is fixed
302
311
print ( #line, genericAnyIs ( type: PC . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
303
312
print ( #line, nongenericAnyIsPAndPCSubType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
304
- print ( #line, genericAnyIs ( type: PCSub . self, to: ( P & PCSub) . self, expected: true ) ) // CHECK: [[@LINE]] false
313
+ print ( #line, genericAnyIs ( type: PCSub . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
305
314
print ( #line, nongenericAnyAsConditionalPAndPCSubType ( type: PS . self) ) // CHECK: [[@LINE]] false
306
315
print ( #line, genericAnyAsConditional ( type: PS . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
307
316
print ( #line, nongenericAnyAsConditionalPAndPCSubType ( type: PE . self) ) // CHECK: [[@LINE]] false
308
317
print ( #line, genericAnyAsConditional ( type: PE . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
309
318
// print(#line, nongenericAnyAsConditionalPAndPCSubType(type: PC.self)) // CHECK-SR-11565: [[@LINE]] false -- FIXME: reenable this when SR-11565 is fixed
310
319
print ( #line, genericAnyAsConditional ( type: PC . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
311
320
print ( #line, nongenericAnyAsConditionalPAndPCSubType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
312
- print ( #line, genericAnyAsConditional ( type: PCSub . self, to: ( P & PCSub) . self, expected: true ) ) // CHECK: [[@LINE]] false
321
+ print ( #line, genericAnyAsConditional ( type: PCSub . self, to: ( P & PCSub) . self, expected: false ) ) // CHECK: [[@LINE]] false
313
322
314
323
315
324
// CHECK-LABEL: type comparisons:
0 commit comments