@@ -313,6 +313,11 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
313313 return sizeof(A) + i;
314314 }
315315 };
316+
317+ template<class ...T> struct RTTest_TemplatedList {};
318+ template<class ...T> auto rttest_make_tlist(T ... args) {
319+ return RTTest_TemplatedList<T...>{};
320+ }
316321 )" ;
317322
318323 GetAllTopLevelDecls (code, Decls, true );
@@ -348,6 +353,16 @@ TEST(FunctionReflectionTest, GetFunctionReturnType) {
348353 EXPECT_EQ (
349354 Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (TemplateSubDecls[3 ])),
350355 " long" );
356+
357+ ASTContext& C = Interp->getCI ()->getASTContext ();
358+ std::vector<Cpp::TemplateArgInfo> args = {C.IntTy .getAsOpaquePtr (),
359+ C.DoubleTy .getAsOpaquePtr ()};
360+ std::vector<Cpp::TemplateArgInfo> explicit_args;
361+ std::vector<Cpp::TCppFunction_t> candidates = {Decls[14 ]};
362+ EXPECT_EQ (
363+ Cpp::GetTypeAsString (Cpp::GetFunctionReturnType (
364+ Cpp::BestOverloadFunctionMatch (candidates, explicit_args, args))),
365+ " RTTest_TemplatedList<int, double>" );
351366}
352367
353368TEST (FunctionReflectionTest, GetFunctionNumArgs) {
@@ -599,6 +614,7 @@ TEST(FunctionReflectionTest, BestOverloadFunctionMatch1) {
599614 template<class A> long get_size();
600615 template<class A, class B> long get_size(A a, B b);
601616 template<class A> long get_size(float a);
617+ template <int N, class T> long get_size(T a);
602618 };
603619
604620 template<class A>
@@ -620,6 +636,11 @@ TEST(FunctionReflectionTest, BestOverloadFunctionMatch1) {
620636 long MyTemplatedMethodClass::get_size(A a, B b) {
621637 return sizeof(A) + sizeof(B);
622638 }
639+
640+ template <int N, class T>
641+ long MyTemplatedMethodClass::get_size(T a) {
642+ return N + sizeof(T) + a;
643+ }
623644 )" ;
624645
625646 GetAllTopLevelDecls (code, Decls);
@@ -638,6 +659,8 @@ TEST(FunctionReflectionTest, BestOverloadFunctionMatch1) {
638659
639660 std::vector<Cpp::TemplateArgInfo> explicit_args0;
640661 std::vector<Cpp::TemplateArgInfo> explicit_args1 = {C.IntTy .getAsOpaquePtr ()};
662+ std::vector<Cpp::TemplateArgInfo> explicit_args2 = {
663+ {C.IntTy .getAsOpaquePtr (), " 1" }, C.IntTy .getAsOpaquePtr ()};
641664
642665 Cpp::TCppFunction_t func1 =
643666 Cpp::BestOverloadFunctionMatch (candidates, explicit_args0, args1);
@@ -647,6 +670,8 @@ TEST(FunctionReflectionTest, BestOverloadFunctionMatch1) {
647670 Cpp::BestOverloadFunctionMatch (candidates, explicit_args0, args2);
648671 Cpp::TCppFunction_t func4 =
649672 Cpp::BestOverloadFunctionMatch (candidates, explicit_args1, args3);
673+ Cpp::TCppFunction_t func5 =
674+ Cpp::BestOverloadFunctionMatch (candidates, explicit_args2, args3);
650675
651676 EXPECT_EQ (Cpp::GetFunctionSignature (func1),
652677 " template<> long MyTemplatedMethodClass::get_size<int>(int &)" );
@@ -656,6 +681,8 @@ TEST(FunctionReflectionTest, BestOverloadFunctionMatch1) {
656681 " template<> long MyTemplatedMethodClass::get_size<char, float>(char a, float b)" );
657682 EXPECT_EQ (Cpp::GetFunctionSignature (func4),
658683 " template<> long MyTemplatedMethodClass::get_size<int>(float a)" );
684+ EXPECT_EQ (Cpp::GetFunctionSignature (func5),
685+ " template<> long MyTemplatedMethodClass::get_size<1, int>(int a)" );
659686}
660687
661688TEST (FunctionReflectionTest, BestOverloadFunctionMatch2) {
0 commit comments