@@ -1272,6 +1272,48 @@ TYPED_TEST(CppInterOpTest, FunctionReflectionTestBestOverloadFunctionMatch4) {
12721272 " template<> void B::fn<int, int>(A<int> x, A<int> y)" );
12731273}
12741274
1275+ TYPED_TEST (CppInterOpTest, FunctionReflectionTestBestOverloadFunctionMatch5) {
1276+ std::vector<Decl*> Decls;
1277+ std::string code = R"(
1278+ template<typename T1, typename T2>
1279+ void callme(T1 t1, T2 t2) {}
1280+
1281+ template <typename F, typename... Args>
1282+ void callback(F callable, Args&&... args) {
1283+ callable(args...);
1284+ }
1285+ )" ;
1286+ GetAllTopLevelDecls (code, Decls);
1287+ EXPECT_EQ (Decls.size (), 2 );
1288+
1289+ std::vector<Cpp::TCppFunction_t> candidates;
1290+ candidates.push_back (Decls[1 ]);
1291+
1292+ ASTContext& C = Interp->getCI ()->getASTContext ();
1293+ std::vector<Cpp::TemplateArgInfo> explicit_params = {
1294+ C.DoubleTy .getAsOpaquePtr (),
1295+ C.IntTy .getAsOpaquePtr (),
1296+ };
1297+
1298+ Cpp::TCppScope_t callme = Cpp::InstantiateTemplate (
1299+ Decls[0 ], explicit_params.data (), explicit_params.size ());
1300+ EXPECT_TRUE (callme);
1301+
1302+ std::vector<Cpp::TemplateArgInfo> arg_types = {
1303+ Cpp::GetTypeFromScope (callme),
1304+ C.getLValueReferenceType (C.DoubleTy ).getAsOpaquePtr (),
1305+ C.getLValueReferenceType (C.IntTy ).getAsOpaquePtr (),
1306+ };
1307+
1308+ Cpp::TCppScope_t callback =
1309+ Cpp::BestOverloadFunctionMatch (candidates, {}, arg_types);
1310+ EXPECT_TRUE (callback);
1311+
1312+ EXPECT_EQ (Cpp::GetFunctionSignature (callback),
1313+ " template<> void callback<void (*)(double, int), <double &, int "
1314+ " &>>(void (*callable)(double, int), double &args, int &args)" );
1315+ }
1316+
12751317TYPED_TEST (CppInterOpTest, FunctionReflectionTestIsPublicMethod) {
12761318 std::vector<Decl *> Decls, SubDecls;
12771319 std::string code = R"(
0 commit comments