mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Reflection: Decode imported Objective-C classes and protocols as their own TypeRef
Right now we expect that every class and protocol has a field descriptor that tells us if the entity is @objc or not. For imported types, the descriptor will not exist if we did not directly emit a field whose concrete type contains the imported type. For example, in lldb, we might have a generic type whose runtime substituted type includes an imported type. In this case, TypeLowering would fail to produce a layout because it did not find a field descriptor for the imported type. A better approach is to have the TypeDecoder call a different factory method for imported types, and handle them specially in TypeLowering, bypassing the field type metadata altogether.
This commit is contained in:
@@ -438,6 +438,16 @@ public:
|
||||
return createNominalType(typeDecl, /*parent*/ Type());
|
||||
}
|
||||
|
||||
ProtocolDecl *createObjCProtocolDecl(StringRef name) {
|
||||
auto typeDecl =
|
||||
findForeignNominalTypeDecl(name, /*relatedEntityKind*/{},
|
||||
ForeignModuleKind::Imported,
|
||||
Demangle::Node::Kind::Protocol);
|
||||
if (auto *protocolDecl = dyn_cast_or_null<ProtocolDecl>(typeDecl))
|
||||
return protocolDecl;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Type createForeignClassType(StringRef mangledName) {
|
||||
auto typeDecl = createNominalTypeDecl(mangledName);
|
||||
if (!typeDecl) return Type();
|
||||
|
||||
Reference in New Issue
Block a user