MetadataReader: Add support for NSError toll-free bridging

An Error existential value can directly store a
reference to an NSError instance without wrapping
it in an Error container.

When "projecting" such an existential, the dynamic type
is the NSError's isa pointer, and the payload is the
address of the instance itself.
This commit is contained in:
Slava Pestov
2019-02-11 01:15:03 -05:00
parent 5824b0f475
commit 76ebaee078
4 changed files with 36 additions and 8 deletions

View File

@@ -500,8 +500,10 @@ public:
Reader.readMetadataAndValueErrorExistential(RemoteAddress(*pointerval));
if (!result)
return getFailure<std::pair<Type, RemoteAddress>>();
RemoteAddress metadataAddress = result->first;
RemoteAddress valueAddress = result->second;
RemoteAddress metadataAddress = std::get<0>(*result);
RemoteAddress valueAddress = std::get<1>(*result);
bool isBridged = std::get<2>(*result);
auto typeResult =
Reader.readTypeFromMetadata(metadataAddress.getAddressData());