@@ -1540,22 +1540,15 @@ void Sema::DiagnoseUnsatisfiedConstraint(
15401540const NormalizedConstraint *Sema::getNormalizedAssociatedConstraints (
15411541 ConstrainedDeclOrNestedRequirement ConstrainedDeclOrNestedReq,
15421542 ArrayRef<AssociatedConstraint> AssociatedConstraints) {
1543- // In case the ConstrainedDecl comes from modules, it is necessary to use
1544- // the canonical decl to avoid different atomic constraints with the 'same'
1545- // declarations.
1546-
15471543 if (!ConstrainedDeclOrNestedReq)
15481544 return NormalizedConstraint::fromAssociatedConstraints (
15491545 *this , nullptr , AssociatedConstraints);
15501546
15511547 const NamedDecl *ND =
15521548 ConstrainedDeclOrNestedReq.dyn_cast <const NamedDecl *>();
1553- if (ND)
1554- ND = cast<NamedDecl>(ND->getCanonicalDecl ());
1555-
15561549 auto CacheEntry = NormalizationCache.find (ConstrainedDeclOrNestedReq);
15571550 if (CacheEntry == NormalizationCache.end ()) {
1558- auto Normalized = NormalizedConstraint::fromAssociatedConstraints (
1551+ auto * Normalized = NormalizedConstraint::fromAssociatedConstraints (
15591552 *this , ND, AssociatedConstraints);
15601553 CacheEntry =
15611554 NormalizationCache.try_emplace (ConstrainedDeclOrNestedReq, Normalized)
@@ -1795,10 +1788,12 @@ NormalizedConstraint *NormalizedConstraint::fromConstraintExpr(
17951788 // constraint. If any such substitution results in an invalid type or
17961789 // expression, the program is ill-formed; no diagnostic is required.
17971790 // [...]
1798- ConceptDecl *CD = CSE->getNamedConcept ();
1791+
1792+ // Use canonical declarations to merge ConceptDecls across
1793+ // different modules.
1794+ ConceptDecl *CD = CSE->getNamedConcept ()->getCanonicalDecl ();
17991795 SubNF = NormalizedConstraint::fromAssociatedConstraints (
1800- S, CSE->getNamedConcept (),
1801- AssociatedConstraint (CD->getConstraintExpr (), SubstIndex));
1796+ S, CD, AssociatedConstraint (CD->getConstraintExpr (), SubstIndex));
18021797
18031798 if (!SubNF)
18041799 return nullptr ;
0 commit comments