@@ -2616,8 +2616,37 @@ size_t TypeSystemSwiftTypeRef::GetIndexOfChildMemberWithName(
2616
2616
2617
2617
size_t
2618
2618
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)));
2620
2648
}
2649
+
2621
2650
CompilerType
2622
2651
TypeSystemSwiftTypeRef::GetTypeForFormatters (opaque_compiler_type_t type) {
2623
2652
return m_swift_ast_context->GetTypeForFormatters (ReconstructType (type));
0 commit comments