@@ -5561,6 +5561,15 @@ static TemplateDeductionResult CheckDeductionConsistency(
5561
5561
// FIXME: A substitution can be incomplete on a non-structural part of the
5562
5562
// type. Use the canonical type for now, until the TemplateInstantiator can
5563
5563
// deal with that.
5564
+
5565
+ // Workaround: Implicit deduction guides use InjectedClassNameTypes, whereas
5566
+ // the explicit guides don't. The substitution doesn't transform these types,
5567
+ // so let it transform their specializations instead.
5568
+ bool IsDeductionGuide = isa<CXXDeductionGuideDecl>(FTD->getTemplatedDecl ());
5569
+ if (IsDeductionGuide) {
5570
+ if (auto *Injected = P->getAs <InjectedClassNameType>())
5571
+ P = Injected->getInjectedSpecializationType ();
5572
+ }
5564
5573
QualType InstP = S.SubstType (P.getCanonicalType (), MLTAL, FTD->getLocation (),
5565
5574
FTD->getDeclName (), &IsIncompleteSubstitution);
5566
5575
if (InstP.isNull () && !IsIncompleteSubstitution)
@@ -5575,9 +5584,15 @@ static TemplateDeductionResult CheckDeductionConsistency(
5575
5584
if (auto *PA = dyn_cast<PackExpansionType>(A);
5576
5585
PA && !isa<PackExpansionType>(InstP))
5577
5586
A = PA->getPattern ();
5578
- if (!S.Context .hasSameType (
5579
- S.Context .getUnqualifiedArrayType (InstP.getNonReferenceType ()),
5580
- S.Context .getUnqualifiedArrayType (A.getNonReferenceType ())))
5587
+ auto T1 = S.Context .getUnqualifiedArrayType (InstP.getNonReferenceType ());
5588
+ auto T2 = S.Context .getUnqualifiedArrayType (A.getNonReferenceType ());
5589
+ if (IsDeductionGuide) {
5590
+ if (auto *Injected = T1->getAs <InjectedClassNameType>())
5591
+ T1 = Injected->getInjectedSpecializationType ();
5592
+ if (auto *Injected = T2->getAs <InjectedClassNameType>())
5593
+ T2 = Injected->getInjectedSpecializationType ();
5594
+ }
5595
+ if (!S.Context .hasSameType (T1, T2))
5581
5596
return TemplateDeductionResult::NonDeducedMismatch;
5582
5597
return TemplateDeductionResult::Success;
5583
5598
}
0 commit comments