summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-reflection-api.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/source/slang/slang-reflection-api.cpp b/source/slang/slang-reflection-api.cpp
index 95dcc6249..c5d39859e 100644
--- a/source/slang/slang-reflection-api.cpp
+++ b/source/slang/slang-reflection-api.cpp
@@ -3471,10 +3471,21 @@ SLANG_API SlangReflectionDecl* spReflectionFunction_asDecl(SlangReflectionFuncti
SLANG_API char const* spReflectionFunction_GetName(SlangReflectionFunction* inFunc)
{
auto func = convertToFunc(inFunc);
- if (!func)
- return nullptr;
+ if (func)
+ return getText(func.getDecl()->getName()).getBuffer();
- return getText(func.getDecl()->getName()).getBuffer();
+ // If convertToFunc failed, this might be an overloaded function.
+ // Try to get the name from the first overload candidate.
+ auto overloadedFunc = convertToOverloadedFunc(inFunc);
+ if (overloadedFunc && overloadedFunc->lookupResult2.items.getCount() > 0)
+ {
+ auto firstOverload = overloadedFunc->lookupResult2.items[0].declRef;
+ if (auto funcDeclRef = firstOverload.as<FunctionDeclBase>())
+ {
+ return getText(funcDeclRef.getDecl()->getName()).getBuffer();
+ }
+ }
+ return nullptr;
}
SLANG_API SlangReflectionType* spReflectionFunction_GetResultType(SlangReflectionFunction* inFunc)