Skip to content

Commit 4671f89

Browse files
committed
Runtime: Use witness table accessors instead of direct witness table references for Error bridging
This breaks with resilient conformances once the pattern symbol is no longer public.
1 parent 8695224 commit 4671f89

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

stdlib/public/runtime/ErrorObject.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,22 +229,22 @@ static Class getSwiftNativeNSErrorClass() {
229229
// Swift source.
230230

231231
auto TheWitnessTable = SWIFT_LAZY_CONSTANT(dlsym(RTLD_DEFAULT,
232-
MANGLE_AS_STRING(MANGLE_SYM(So10CFErrorRefas5Error10FoundationWP))));
232+
MANGLE_AS_STRING(MANGLE_SYM(So10CFErrorRefas5Error10FoundationWa))));
233233
assert(TheWitnessTable &&
234234
"Foundation overlay not loaded, or 'CFError : Error' conformance "
235235
"not available");
236236

237-
return reinterpret_cast<const WitnessTable *>(TheWitnessTable);
237+
return reinterpret_cast<const SWIFT_CC(swift) WitnessTable *(*)()>(TheWitnessTable)();
238238
}
239239

240240
static const HashableWitnessTable *getNSErrorConformanceToHashable() {
241241
auto TheWitnessTable = SWIFT_LAZY_CONSTANT(dlsym(RTLD_DEFAULT,
242-
MANGLE_AS_STRING(MANGLE_SYM(So8NSObjectCs8Hashable10ObjectiveCWP))));
242+
MANGLE_AS_STRING(MANGLE_SYM(So8NSObjectCs8Hashable10ObjectiveCWa))));
243243
assert(TheWitnessTable &&
244244
"ObjectiveC overlay not loaded, or 'NSObject : Hashable' conformance "
245245
"not available");
246246

247-
return reinterpret_cast<const HashableWitnessTable *>(TheWitnessTable);
247+
return reinterpret_cast<const SWIFT_CC(swift) HashableWitnessTable *(*)()>(TheWitnessTable)();
248248
}
249249

250250
bool SwiftError::isPureNSError() const {

0 commit comments

Comments
 (0)