@@ -5794,9 +5794,11 @@ bool SemanticsVisitor::doesGenericSignatureMatchRequirement(
57945794 //
57955795
57965796 auto getNonEmptyConstraintTargetDeclRef =
5797- [&](NonEmptyPackConstraintDecl* constraintDecl ) -> DeclRef<Decl>
5797+ [&](DeclRef< NonEmptyPackConstraintDecl> const& constraintDeclRef ) -> DeclRef<Decl>
57985798 {
5799- if (auto declRefExpr = as<DeclRefExpr>(constraintDecl->packExpr))
5799+ auto packExpr =
5800+ constraintDeclRef.substitute(m_astBuilder, constraintDeclRef.getDecl()->packExpr);
5801+ if (auto declRefExpr = packExpr.as<DeclRefExpr>())
58005802 return getDeclRef(m_astBuilder, declRefExpr);
58015803 return DeclRef<Decl>();
58025804 };
@@ -6044,30 +6046,6 @@ bool SemanticsVisitor::doesGenericSignatureMatchRequirement(
60446046 }
60456047 }
60466048
6047- // Constraint checks below compare declarations after the required signature has been aligned to
6048- // the satisfying signature. Some substituted decl refs still point at the original required
6049- // binder, so treat paired generic parameters as equivalent when they occupy the same signature
6050- // slot and the structural parameter checks above have already matched their kinds.
6051- auto areGenericSignatureDeclRefsAligned = [&](DeclRef<Decl> requiredDeclRef,
6052- DeclRef<Decl> satisfyingDeclRef) -> bool
6053- {
6054- if (requiredDeclRef.equals(satisfyingDeclRef))
6055- return true;
6056- if (!requiredDeclRef || !satisfyingDeclRef)
6057- return false;
6058-
6059- for (Index i = 0; i < requiredParams.getCount(); i++)
6060- {
6061- if (requiredParams[i].getDecl() == requiredDeclRef.getDecl() &&
6062- satisfyingParams[i].getDecl() == satisfyingDeclRef.getDecl())
6063- {
6064- return true;
6065- }
6066- }
6067-
6068- return false;
6069- };
6070-
60716049 for (Index i = 0; i < requiredConstraints.getCount(); i++)
60726050 {
60736051 auto requiredMemberDeclRef = requiredConstraints[i];
@@ -6282,10 +6260,10 @@ bool SemanticsVisitor::doesGenericSignatureMatchRequirement(
62826260 return false;
62836261
62846262 auto requiredPackTarget =
6285- getNonEmptyConstraintTargetDeclRef(specializedRequiredConstraintDeclRef.getDecl() );
6263+ getNonEmptyConstraintTargetDeclRef(specializedRequiredConstraintDeclRef);
62866264 auto satisfyingPackTarget =
6287- getNonEmptyConstraintTargetDeclRef(satisfyingConstraintDeclRef.getDecl() );
6288- if (!areGenericSignatureDeclRefsAligned( requiredPackTarget, satisfyingPackTarget))
6265+ getNonEmptyConstraintTargetDeclRef(satisfyingConstraintDeclRef);
6266+ if (!requiredPackTarget.equals( satisfyingPackTarget))
62896267 {
62906268 return false;
62916269 }
@@ -6316,7 +6294,7 @@ bool SemanticsVisitor::doesGenericSignatureMatchRequirement(
63166294 specializedRequiredConstraintDeclRef);
63176295 auto satisfyingPackTarget =
63186296 getPackCountConstraintTargetDeclRef(m_astBuilder, satisfyingConstraintDeclRef);
6319- if (!areGenericSignatureDeclRefsAligned( requiredPackTarget, satisfyingPackTarget))
6297+ if (!requiredPackTarget.equals( satisfyingPackTarget))
63206298 {
63216299 return false;
63226300 }
0 commit comments