File tree Expand file tree Collapse file tree 2 files changed +12
-20
lines changed Expand file tree Collapse file tree 2 files changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -1171,25 +1171,6 @@ static bool isObjCForUnownedReference(void *value) {
11711171 if (object == nullptr )
11721172 return nullptr ;
11731173
1174- #pragma clang diagnostic push
1175- #pragma clang diagnostic ignored "-Wreceiver-forward-class"
1176- if ([id_const_cast (object) isKindOfClass: [__SwiftValue class ]]) {
1177- #pragma clang diagnostic pop
1178- // Source is a `__SwiftValue` container
1179- // Unwrap, then use the most general casting machine to do the heavy lifting
1180- auto typeValue = getValueFromSwiftValue (reinterpret_cast <__SwiftValue *>(object));
1181- const void *result = nullptr ;
1182- if (swift_dynamicCast (reinterpret_cast <OpaqueValue *>(&result),
1183- const_cast <OpaqueValue *>(typeValue.second ),
1184- typeValue.first ,
1185- targetType,
1186- DynamicCastFlags::TakeOnSuccess)) {
1187- return result;
1188- } else {
1189- return nullptr ;
1190- }
1191- }
1192-
11931174 if ([id_const_cast (object) isKindOfClass: class_const_cast (targetType)]) {
11941175 return object;
11951176 }
Original file line number Diff line number Diff line change @@ -1065,13 +1065,24 @@ CastsTests.test("Don't put AnyHashable inside AnyObject") {
10651065}
10661066
10671067#if _runtime(_ObjC)
1068- CastsTests . test ( " __SwiftValue should not be obvious to `is` " ) {
1068+ // We currently (as of Jan 2024) bridge NSSet to Swift with `x as!
1069+ // Set<NSObject>`, which in turn demands that __SwiftValue successfully cast to
1070+ // NSObject.
1071+ // So this nonsensical behavior can probably never be fixed.
1072+ // (It's nonsense because it implies that every Swift object is derived
1073+ // from NSObject.) See PR #68952 for an early attempt to change it which
1074+ // had to be reverted.
1075+ CastsTests . test ( " __SwiftValue should not be obvious to `is` " )
1076+ . xfail ( . always( " Probably can never be fixed " ) )
1077+ . code {
10691078 struct S { }
10701079 let s = S ( ) as AnyObject
10711080 expectFalse ( s is NSObject )
10721081}
10731082#endif
10741083
1084+ // See above for reasons why this might need to remain broken forever,
1085+ // though I do have some hope for it.
10751086CastsTests . test ( " type(of:) should look through __SwiftValue " )
10761087. xfail ( . always( " Known to be broken " ) )
10771088. code {
You can’t perform that action at this time.
0 commit comments