@@ -311,6 +311,33 @@ isDecayedEqual(
311311{
312312 return isDecayedEqualImpl<false >(lhs, rhs, context, corpus);
313313}
314+
315+ bool
316+ isDecayedEqual (
317+ Polymorphic<TArg> const & lhs,
318+ Polymorphic<TArg> const & rhs,
319+ Info const & context,
320+ CorpusImpl const & corpus)
321+ {
322+ if (lhs->Kind != rhs->Kind )
323+ {
324+ return false ;
325+ }
326+ if (lhs->isType ())
327+ {
328+ return isDecayedEqualImpl<true >(
329+ get<TypeTArg>(lhs).Type ,
330+ get<TypeTArg>(rhs).Type ,
331+ context, corpus);
332+ }
333+ if (lhs->isNonType ())
334+ {
335+ return
336+ trim (get<NonTypeTArg>(lhs).Value .Written ) ==
337+ trim (get<NonTypeTArg>(rhs).Value .Written );
338+ }
339+ return false ;
340+ }
314341}
315342
316343Expected<std::reference_wrapper<Info const >>
@@ -353,7 +380,7 @@ lookupImpl(Self&& self, SymbolID const& contextId0, std::string_view name)
353380 }
354381 return std::cref (*info);
355382 }
356- Expected<ParsedRef> const expRef = parseRef (name);
383+ auto const expRef = parse<ParsedRef> (name);
357384 if (!expRef)
358385 {
359386 return Unexpected (formatError (" Failed to parse '{}'\n {}" , name, expRef.error ().reason ()));
@@ -494,7 +521,7 @@ lookupImpl(
494521 };
495522 auto const highestMatchLevel =
496523 !checkParameters || !ref.HasFunctionParameters ?
497- MatchLevel::TemplateArgsSize :
524+ MatchLevel::TemplateArgs :
498525 MatchLevel::Qualifiers;
499526 auto matchLevel = MatchLevel::None;
500527 Info const * res = nullptr ;
@@ -535,29 +562,41 @@ lookupImpl(
535562 }
536563 matchRes = MatchLevel::Name;
537564
538- // Template arguments match
539- if constexpr (requires { M.Template ; })
540- {
541- std::optional<TemplateInfo> const & templateInfo = M.Template ;
542- if (component.TemplateArguments .empty ())
565+ // Template arguments size match
566+ TemplateInfo const * templateInfo = [&]() -> TemplateInfo const * {
567+ if constexpr (requires { M.Template ; })
543568 {
544- MRDOCS_CHECK_OR (
545- !templateInfo.has_value () ||
546- templateInfo->Args .empty (), matchRes);
569+ std::optional<TemplateInfo> const & OTI = M.Template ;
570+ MRDOCS_CHECK_OR (OTI, nullptr );
571+ TemplateInfo const & TI = *OTI;
572+ return &TI;
547573 }
548574 else
549575 {
550- MRDOCS_CHECK_OR (
551- templateInfo.has_value () &&
552- templateInfo->Args .size () == component.TemplateArguments .size (), matchRes);
576+ return nullptr ;
553577 }
578+ }();
579+ if (!templateInfo)
580+ {
581+ MRDOCS_CHECK_OR (!component.HasTemplateArguments , matchRes);
554582 }
555583 else
556584 {
557- MRDOCS_CHECK_OR (component.TemplateArguments .empty (), matchRes);
585+ MRDOCS_CHECK_OR (templateInfo-> Args . size () == component.TemplateArguments .size (), matchRes);
558586 }
559587 matchRes = MatchLevel::TemplateArgsSize;
560588
589+ if (templateInfo)
590+ {
591+ for (std::size_t i = 0 ; i < templateInfo->Args .size (); ++i)
592+ {
593+ auto & lhsType = templateInfo->Args [i];
594+ auto & rhsType = component.TemplateArguments [i];
595+ MRDOCS_CHECK_OR (isDecayedEqual (lhsType, rhsType, context, *this ), matchRes);
596+ }
597+ }
598+ matchRes = MatchLevel::TemplateArgs;
599+
561600 // Function parameters size match
562601 MRDOCS_CHECK_OR (checkParameters && ref.HasFunctionParameters , matchRes);
563602 MRDOCS_CHECK_OR (MInfoTy::isFunction (), matchRes);
0 commit comments