From 7c7573b5902ec18bd67991e40a7ba309f826412a Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Fri, 27 Jun 2025 17:21:35 +0200 Subject: [PATCH] fix: JITCall codegen to deal with enums and funcs with same name --- lib/CppInterOp/CppInterOp.cpp | 1 + unittests/CppInterOp/FunctionReflectionTest.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/CppInterOp/CppInterOp.cpp b/lib/CppInterOp/CppInterOp.cpp index f0d7b2b38..afbd0e368 100755 --- a/lib/CppInterOp/CppInterOp.cpp +++ b/lib/CppInterOp/CppInterOp.cpp @@ -1837,6 +1837,7 @@ void get_type_as_string(QualType QT, std::string& type_name, ASTContext& C, #if CLANG_VERSION_MAJOR > 16 Policy.SuppressElaboration = true; #endif + Policy.SuppressTagKeyword = !QT->isEnumeralType(); Policy.FullyQualifiedName = true; QT.getAsStringInternal(type_name, Policy); } diff --git a/unittests/CppInterOp/FunctionReflectionTest.cpp b/unittests/CppInterOp/FunctionReflectionTest.cpp index 28a64252f..b69d7c701 100644 --- a/unittests/CppInterOp/FunctionReflectionTest.cpp +++ b/unittests/CppInterOp/FunctionReflectionTest.cpp @@ -1994,6 +1994,21 @@ TEST(FunctionReflectionTest, GetFunctionCallWrapper) { auto tuple_tuple_callable = Cpp::MakeFunctionCallable(tuple_tuple); EXPECT_EQ(tuple_tuple_callable.getKind(), Cpp::JitCall::kGenericCall); + + Interp->process(R"( + namespace EnumFunctionSameName { + enum foo { FOO = 42 }; + void foo() {} + unsigned int bar(enum foo f) { return (unsigned int)f; } + } + )"); + + Cpp::TCppScope_t bar = + Cpp::GetNamed("bar", Cpp::GetScope("EnumFunctionSameName")); + EXPECT_TRUE(bar); + + auto bar_callable = Cpp::MakeFunctionCallable(bar); + EXPECT_EQ(bar_callable.getKind(), Cpp::JitCall::kGenericCall); } TEST(FunctionReflectionTest, IsConstMethod) {