From 2b87c00c671b156b8e5926f8967003bf12c65aa7 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Sat, 27 Apr 2024 02:27:28 -0400 Subject: Fix invoke resolution when dealing with overloded type expressions (#4043) --- source/slang/slang-check-overload.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'source/slang') diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 6180ccda8..703771e6e 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -2093,7 +2093,21 @@ namespace Slang typeCheckingCache->resolvedOperatorOverloadCache[key] = *context.bestCandidate; return CompleteOverloadCandidate(context, *context.bestCandidate); } - else if (auto typetype = as(funcExprType)) + + // If absolutely no viable candidates were extracted from the overloaded expression, + // we may be dealing with a composite type or an overloaded expression with composite types. + // + + auto typeExpr = funcExpr; + if (auto overloadedExpr = as(funcExpr)) + { + if (overloadedExpr->lookupResult2.isValid() && overloadedExpr->lookupResult2.isOverloaded()) + { + typeExpr = maybeResolveOverloadedExpr(overloadedExpr, LookupMask::type, nullptr); + } + } + + if (auto typetype = as(typeExpr->type)) { // We allow a special case when `funcExpr` represents a composite type, // in which case we will try to construct the type via memberwise assignment from the arguments. -- cgit v1.2.3