File tree Expand file tree Collapse file tree 2 files changed +0
-32
lines changed Expand file tree Collapse file tree 2 files changed +0
-32
lines changed Original file line number Diff line number Diff line change @@ -1353,15 +1353,6 @@ id swift_dynamicCastObjCProtocolUnconditional(id object,
1353
1353
Protocol * const *protocols,
1354
1354
const char *filename,
1355
1355
unsigned line, unsigned column) {
1356
- if (numProtocols == 0 ) {
1357
- return object;
1358
- }
1359
- if (object_isClass (object)) {
1360
- // ObjC classes never conform to protocols
1361
- Class sourceType = object_getClass (object);
1362
- swift_dynamicCastFailure (sourceType, class_getName (sourceType),
1363
- protocols[0 ], protocol_getName (protocols[0 ]));
1364
- }
1365
1356
for (size_t i = 0 ; i < numProtocols; ++i) {
1366
1357
if (![object conformsToProtocol: protocols[i]]) {
1367
1358
Class sourceType = object_getClass (object);
@@ -1383,10 +1374,6 @@ id swift_dynamicCastObjCProtocolConditional(id object,
1383
1374
return nil ;
1384
1375
}
1385
1376
}
1386
- if (object_isClass (object)) {
1387
- // ObjC classes never conform to protocols
1388
- return nil ;
1389
- }
1390
1377
for (size_t i = 0 ; i < numProtocols; ++i) {
1391
1378
if (![object conformsToProtocol: protocols[i]]) {
1392
1379
return nil ;
Original file line number Diff line number Diff line change @@ -1081,23 +1081,4 @@ CastsTests.test("type(of:) should look through __SwiftValue")
1081
1081
expectEqual ( t, " S " ) // Fails: currently says `__SwiftValue`
1082
1082
}
1083
1083
1084
- #if _runtime(_ObjC)
1085
- @objc protocol P106973771 {
1086
- func sayHello( )
1087
- }
1088
- CastsTests . test ( " Class metatype values should not cast to Obj-C existentials " ) {
1089
- class C106973771 : NSObject , P106973771 {
1090
- func sayHello( ) { print ( " Hello " ) }
1091
- }
1092
- // A class instance clearly conforms to the protocol
1093
- expectTrue ( C106973771 ( ) is any P106973771 )
1094
- // But the metatype definitely does not
1095
- expectFalse ( C106973771 . self is any P106973771 )
1096
- // The cast should not succeed
1097
- expectNil ( C106973771 . self as? any P106973771 )
1098
- // The following will crash if the cast succeeds
1099
- ( C106973771 . self as? any P106973771 ) ? . sayHello ( )
1100
- }
1101
- #endif
1102
-
1103
1084
runAllTests ( )
You can’t perform that action at this time.
0 commit comments