@@ -577,3 +577,65 @@ TEST_F(TestTypeSystemSwiftTypeRef, ImportedType) {
577
577
TEST_F (TestTypeSystemSwiftTypeRef, RawPointer) {
578
578
ASSERT_EQ (m_swift_ts.GetRawPointerType ().GetMangledTypeName (), " $sBpD" );
579
579
}
580
+
581
+ TEST_F (TestTypeSystemSwiftTypeRef, GetNumTemplateArguments) {
582
+ using namespace swift ::Demangle;
583
+ Demangler dem;
584
+ NodeBuilder b (dem);
585
+ {
586
+ NodePointer n = b.GlobalType (b.Node (
587
+ Node::Kind::BoundGenericClass,
588
+ b.Node (Node::Kind::Type,
589
+ b.Node (Node::Kind::Class, b.Node (Node::Kind::Module, " module" ),
590
+ b.Node (Node::Kind::Identifier, " Foo" ))),
591
+ b.Node (Node::Kind::TypeList,
592
+ b.Node (Node::Kind::Type,
593
+ b.Node (Node::Kind::DependentGenericParamType,
594
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
595
+ b.NodeWithIndex (Node::Kind::Index, 0 ))),
596
+ b.Node (Node::Kind::Type,
597
+ b.Node (Node::Kind::DependentGenericParamType,
598
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
599
+ b.NodeWithIndex (Node::Kind::Index, 1 ))),
600
+ b.Node (Node::Kind::Type,
601
+ b.Node (Node::Kind::DependentGenericParamType,
602
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
603
+ b.NodeWithIndex (Node::Kind::Index, 2 ))))));
604
+ CompilerType t = GetCompilerType (b.Mangle (n));
605
+ ASSERT_EQ (t.GetNumTemplateArguments (), 3 );
606
+ }
607
+
608
+ {
609
+ NodePointer n = b.GlobalType (b.Node (
610
+ Node::Kind::BoundGenericStructure,
611
+ b.Node (Node::Kind::Type,
612
+ b.Node (Node::Kind::Structure, b.Node (Node::Kind::Module, " module" ),
613
+ b.Node (Node::Kind::Identifier, " Foo" ))),
614
+ b.Node (Node::Kind::TypeList,
615
+ b.Node (Node::Kind::Type,
616
+ b.Node (Node::Kind::DependentGenericParamType,
617
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
618
+ b.NodeWithIndex (Node::Kind::Index, 0 ))),
619
+ b.Node (Node::Kind::Type,
620
+ b.Node (Node::Kind::DependentGenericParamType,
621
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
622
+ b.NodeWithIndex (Node::Kind::Index, 1 ))))));
623
+ CompilerType t = GetCompilerType (b.Mangle (n));
624
+ ASSERT_EQ (t.GetNumTemplateArguments (), 2 );
625
+ }
626
+
627
+ {
628
+ NodePointer n = b.GlobalType (b.Node (
629
+ Node::Kind::BoundGenericEnum,
630
+ b.Node (Node::Kind::Type,
631
+ b.Node (Node::Kind::Enum, b.Node (Node::Kind::Module, " module" ),
632
+ b.Node (Node::Kind::Identifier, " Foo" ))),
633
+ b.Node (Node::Kind::TypeList,
634
+ b.Node (Node::Kind::Type,
635
+ b.Node (Node::Kind::DependentGenericParamType,
636
+ b.NodeWithIndex (Node::Kind::Index, 0 ),
637
+ b.NodeWithIndex (Node::Kind::Index, 0 ))))));
638
+ CompilerType t = GetCompilerType (b.Mangle (n));
639
+ ASSERT_EQ (t.GetNumTemplateArguments (), 1 );
640
+ }
641
+ }
0 commit comments