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) {
1171
1171
if (object == nullptr )
1172
1172
return nullptr ;
1173
1173
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
-
1193
1174
if ([id_const_cast (object) isKindOfClass: class_const_cast (targetType)]) {
1194
1175
return object;
1195
1176
}
Original file line number Diff line number Diff line change @@ -1065,13 +1065,24 @@ CastsTests.test("Don't put AnyHashable inside AnyObject") {
1065
1065
}
1066
1066
1067
1067
#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 {
1069
1078
struct S { }
1070
1079
let s = S ( ) as AnyObject
1071
1080
expectFalse ( s is NSObject )
1072
1081
}
1073
1082
#endif
1074
1083
1084
+ // See above for reasons why this might need to remain broken forever,
1085
+ // though I do have some hope for it.
1075
1086
CastsTests . test ( " type(of:) should look through __SwiftValue " )
1076
1087
. xfail ( . always( " Known to be broken " ) )
1077
1088
. code {
You can’t perform that action at this time.
0 commit comments