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,
13531353 Protocol * const *protocols,
13541354 const char *filename,
13551355 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- }
13651356 for (size_t i = 0 ; i < numProtocols; ++i) {
13661357 if (![object conformsToProtocol: protocols[i]]) {
13671358 Class sourceType = object_getClass (object);
@@ -1383,10 +1374,6 @@ id swift_dynamicCastObjCProtocolConditional(id object,
13831374 return nil ;
13841375 }
13851376 }
1386- if (object_isClass (object)) {
1387- // ObjC classes never conform to protocols
1388- return nil ;
1389- }
13901377 for (size_t i = 0 ; i < numProtocols; ++i) {
13911378 if (![object conformsToProtocol: protocols[i]]) {
13921379 return nil ;
Original file line number Diff line number Diff line change @@ -1081,23 +1081,4 @@ CastsTests.test("type(of:) should look through __SwiftValue")
10811081 expectEqual ( t, " S " ) // Fails: currently says `__SwiftValue`
10821082}
10831083
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-
11031084runAllTests ( )
You can’t perform that action at this time.
0 commit comments