summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-overload.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-01-17 08:55:57 -0800
committerGitHub <noreply@github.com>2025-01-17 08:55:57 -0800
commit3666c66e26f90b10031578e9c8b8f2ea118aecf9 (patch)
treea9564b3becf23d17b3183d97689c126819ffce9e /source/slang/slang-check-overload.cpp
parentdfb369e87dd7638e84efe8feb9e7069e5238b44c (diff)
Fix prebound parameter pack - argument list matching logic. (#6111)
* Fix prebound parameter pack - argument list matching logic. * Move tests. * Fix.
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
-rw-r--r--source/slang/slang-check-overload.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp
index fcc6780b6..1ab3aa5b0 100644
--- a/source/slang/slang-check-overload.cpp
+++ b/source/slang/slang-check-overload.cpp
@@ -10,6 +10,17 @@
namespace Slang
{
+
+bool isFreeFormTypePackParam(SemanticsVisitor* visitor, Type* type, ParamDecl* paramDecl)
+{
+ if (auto declRef = isDeclRefTypeOf<GenericTypePackParamDecl>(type))
+ {
+ return visitor->GetOuterGeneric(declRef.getDecl()) ==
+ visitor->GetOuterGeneric(paramDecl->parentDecl);
+ }
+ return false;
+}
+
SemanticsVisitor::ParamCounts SemanticsVisitor::CountParameters(
FilteredMemberRefList<ParamDecl> params)
{
@@ -25,10 +36,15 @@ SemanticsVisitor::ParamCounts SemanticsVisitor::CountParameters(
counts.required += typePack->getTypeCount();
allowedArgCountToAdd = typePack->getTypeCount();
}
- else
+ else if (isFreeFormTypePackParam(this, paramType, param.getDecl()))
{
counts.allowed = -1;
}
+ else
+ {
+ counts.required++;
+ counts.allowed++;
+ }
}
else if (!param.getDecl()->initExpr)
{