Skip to content

Commit 86fe7fd

Browse files
committed
RemoteAST: Fix error existential introspection on Linux
1 parent 4b44fed commit 86fe7fd

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -361,24 +361,21 @@ class MetadataReader {
361361
bool isObjC = false;
362362
bool isBridged = false;
363363

364-
// If we can determine the Objective-C class name, this is probably an
365-
// error existential with NSError-compatible layout.
366-
std::string ObjCClassName;
367-
if (readObjCClassName(*MetadataAddress, ObjCClassName)) {
368-
if (ObjCClassName == "__SwiftNativeNSError")
369-
isObjC = true;
370-
else
364+
auto Meta = readMetadata(*MetadataAddress);
365+
if (auto ClassMeta = dyn_cast<TargetClassMetadata<Runtime>>(Meta)) {
366+
if (ClassMeta->isPureObjC()) {
367+
// If we can determine the Objective-C class name, this is probably an
368+
// error existential with NSError-compatible layout.
369+
std::string ObjCClassName;
370+
if (readObjCClassName(*MetadataAddress, ObjCClassName)) {
371+
if (ObjCClassName == "__SwiftNativeNSError")
372+
isObjC = true;
373+
else
374+
isBridged = true;
375+
}
376+
} else {
371377
isBridged = true;
372-
} else {
373-
// Otherwise, we can check to see if this is a class metadata with the
374-
// kind value's least significant bit set, which indicates a pure
375-
// Swift class.
376-
auto Meta = readMetadata(*MetadataAddress);
377-
auto ClassMeta = dyn_cast<TargetClassMetadata<Runtime>>(Meta);
378-
if (!ClassMeta)
379-
return None;
380-
381-
isObjC = ClassMeta->isPureObjC();
378+
}
382379
}
383380

384381
if (isBridged) {

test/RemoteAST/existentials.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// UNSUPPORTED: linux
2-
// <rdar://problem/42793848>
31
// RUN: %target-swift-remoteast-test %s | %FileCheck %s
42

53
// REQUIRES: swift-remoteast-test

0 commit comments

Comments
 (0)