@@ -311,6 +311,33 @@ isDecayedEqual(
311
311
{
312
312
return isDecayedEqualImpl<false >(lhs, rhs, context, corpus);
313
313
}
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
+ }
314
341
}
315
342
316
343
Expected<std::reference_wrapper<Info const >>
@@ -353,7 +380,7 @@ lookupImpl(Self&& self, SymbolID const& contextId0, std::string_view name)
353
380
}
354
381
return std::cref (*info);
355
382
}
356
- Expected<ParsedRef> const expRef = parseRef (name);
383
+ auto const expRef = parse<ParsedRef> (name);
357
384
if (!expRef)
358
385
{
359
386
return Unexpected (formatError (" Failed to parse '{}'\n {}" , name, expRef.error ().reason ()));
@@ -494,7 +521,7 @@ lookupImpl(
494
521
};
495
522
auto const highestMatchLevel =
496
523
!checkParameters || !ref.HasFunctionParameters ?
497
- MatchLevel::TemplateArgsSize :
524
+ MatchLevel::TemplateArgs :
498
525
MatchLevel::Qualifiers;
499
526
auto matchLevel = MatchLevel::None;
500
527
Info const * res = nullptr ;
@@ -535,29 +562,41 @@ lookupImpl(
535
562
}
536
563
matchRes = MatchLevel::Name;
537
564
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 ; })
543
568
{
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;
547
573
}
548
574
else
549
575
{
550
- MRDOCS_CHECK_OR (
551
- templateInfo.has_value () &&
552
- templateInfo->Args .size () == component.TemplateArguments .size (), matchRes);
576
+ return nullptr ;
553
577
}
578
+ }();
579
+ if (!templateInfo)
580
+ {
581
+ MRDOCS_CHECK_OR (!component.HasTemplateArguments , matchRes);
554
582
}
555
583
else
556
584
{
557
- MRDOCS_CHECK_OR (component.TemplateArguments .empty (), matchRes);
585
+ MRDOCS_CHECK_OR (templateInfo-> Args . size () == component.TemplateArguments .size (), matchRes);
558
586
}
559
587
matchRes = MatchLevel::TemplateArgsSize;
560
588
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
+
561
600
// Function parameters size match
562
601
MRDOCS_CHECK_OR (checkParameters && ref.HasFunctionParameters , matchRes);
563
602
MRDOCS_CHECK_OR (MInfoTy::isFunction (), matchRes);
0 commit comments