@@ -16,9 +16,12 @@ enum PE: P {}
16
16
class PC : P , PObjC { }
17
17
class PCSub : PC { }
18
18
19
- func nongenericAnyIsPObjC ( type: Any . Type ) -> Bool {
19
+ func nongenericAnyIsPObjCType ( type: Any . Type ) -> Bool {
20
20
return type is PObjC . Type
21
21
}
22
+ func nongenericAnyIsPObjCProtocol( type: Any . Type ) -> Bool {
23
+ return type is PObjC . Protocol
24
+ }
22
25
func genericAnyIs< T> ( type: Any . Type , to: T . Type , expected: Bool ) -> Bool {
23
26
// If we're testing against a runtime that doesn't have the fix this tests,
24
27
// just pretend we got it right.
@@ -29,13 +32,23 @@ func genericAnyIs<T>(type: Any.Type, to: T.Type, expected: Bool) -> Bool {
29
32
}
30
33
}
31
34
32
- // CHECK-LABEL: casting types to ObjC protocols with generics:
33
- print ( " casting types to ObjC protocols with generics: " )
34
- print ( nongenericAnyIsPObjC ( type: PS . self) ) // CHECK: false
35
- print ( genericAnyIs ( type: PS . self, to: PObjC . self, expected: false ) ) // CHECK: false
36
- print ( nongenericAnyIsPObjC ( type: PE . self) ) // CHECK: false
37
- print ( genericAnyIs ( type: PE . self, to: PObjC . self, expected: false ) ) // CHECK: false
38
- print ( nongenericAnyIsPObjC ( type: PC . self) ) // CHECK: true
39
- print ( genericAnyIs ( type: PC . self, to: PObjC . self, expected: true ) ) // CHECK-ONONE: true
40
- print ( nongenericAnyIsPObjC ( type: PCSub . self) ) // CHECK: true
41
- print ( genericAnyIs ( type: PCSub . self, to: PObjC . self, expected: true ) ) // CHECK-ONONE: true
35
+ // CHECK-LABEL: casting types to ObjC protocol existential metatype:
36
+ print ( " casting types to ObjC protocol existential metatype: " )
37
+ print ( #line, nongenericAnyIsPObjCType ( type: PS . self) ) // CHECK: [[@LINE]] false
38
+ print ( #line, nongenericAnyIsPObjCType ( type: PE . self) ) // CHECK: [[@LINE]] false
39
+ print ( #line, nongenericAnyIsPObjCType ( type: PC . self) ) // CHECK: [[@LINE]] true
40
+ print ( #line, nongenericAnyIsPObjCType ( type: PCSub . self) ) // CHECK: [[@LINE]] true
41
+
42
+ // CHECK-LABEL: casting types to ObjC protocol metatype:
43
+ print ( " casting types to ObjC protocol metatype: " )
44
+ print ( #line, nongenericAnyIsPObjCProtocol ( type: PS . self) ) // CHECK: [[@LINE]] false
45
+ print ( #line, nongenericAnyIsPObjCProtocol ( type: PE . self) ) // CHECK: [[@LINE]] false
46
+ print ( #line, nongenericAnyIsPObjCProtocol ( type: PC . self) ) // CHECK: [[@LINE]] false
47
+ print ( #line, nongenericAnyIsPObjCProtocol ( type: PCSub . self) ) // CHECK: [[@LINE]] false
48
+
49
+ // CHECK-LABEL: casting types to ObjC protocol metatype via generic:
50
+ print ( " casting types to ObjC protocol metatype via generic: " )
51
+ print ( #line, genericAnyIs ( type: PS . self, to: PObjC . self, expected: false ) ) // CHECK: [[@LINE]] false
52
+ print ( #line, genericAnyIs ( type: PE . self, to: PObjC . self, expected: false ) ) // CHECK: [[@LINE]] false
53
+ print ( #line, genericAnyIs ( type: PC . self, to: PObjC . self, expected: true ) ) // CHECK-ONONE: [[@LINE]] false
54
+ print ( #line, genericAnyIs ( type: PCSub . self, to: PObjC . self, expected: true ) ) // CHECK-ONONE: [[@LINE]] false
0 commit comments