Skip to content

Commit dc65450

Browse files
committed
Implement TypeSystemSwiftTypeRef::GetNumTemplateArguments
1 parent af5aaa7 commit dc65450

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2616,8 +2616,37 @@ size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
26162616

26172617
size_t
26182618
TypeSystemSwiftTypeRef::GetNumTemplateArguments(opaque_compiler_type_t type) {
2619-
return m_swift_ast_context->GetNumTemplateArguments(ReconstructType(type));
2619+
auto impl = [&]() -> size_t {
2620+
using namespace swift::Demangle;
2621+
Demangler dem;
2622+
NodePointer node = DemangleCanonicalType(dem, type);
2623+
2624+
if (!node)
2625+
return 0;
2626+
2627+
switch (node->getKind()) {
2628+
case Node::Kind::BoundGenericClass:
2629+
case Node::Kind::BoundGenericEnum:
2630+
case Node::Kind::BoundGenericStructure:
2631+
case Node::Kind::BoundGenericProtocol:
2632+
case Node::Kind::BoundGenericOtherNominalType:
2633+
case Node::Kind::BoundGenericTypeAlias:
2634+
case Node::Kind::BoundGenericFunction: {
2635+
if (node->getNumChildren() > 1) {
2636+
NodePointer child = node->getChild(1);
2637+
if (child && child->getKind() == Node::Kind::TypeList)
2638+
return child->getNumChildren();
2639+
}
2640+
} break;
2641+
default:
2642+
break;
2643+
}
2644+
return 0;
2645+
};
2646+
VALIDATE_AND_RETURN(impl, GetNumTemplateArguments, type,
2647+
(ReconstructType(type)), (ReconstructType(type)));
26202648
}
2649+
26212650
CompilerType
26222651
TypeSystemSwiftTypeRef::GetTypeForFormatters(opaque_compiler_type_t type) {
26232652
return m_swift_ast_context->GetTypeForFormatters(ReconstructType(type));

0 commit comments

Comments
 (0)