@@ -4502,6 +4502,7 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
4502
4502
// Check whether we have a reasonable constraint type at all.
4503
4503
if (!constraintType->is <ProtocolType>() &&
4504
4504
!constraintType->is <ProtocolCompositionType>() &&
4505
+ !constraintType->is <ParametrizedProtocolType>() &&
4505
4506
!constraintType->getClassOrBoundGenericClass ()) {
4506
4507
if (source.getLoc ().isValid () && !constraintType->hasError ()) {
4507
4508
Impl->HadAnyError = true ;
@@ -4514,8 +4515,30 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
4514
4515
return ConstraintResult::Conflicting;
4515
4516
}
4516
4517
4518
+ // Parametrized protocol requirements.
4519
+ if (auto *paramProtoType = constraintType->getAs <ParametrizedProtocolType>()) {
4520
+ bool anyErrors = false ;
4521
+
4522
+ auto *protoDecl = paramProtoType->getBaseType ()->getDecl ();
4523
+
4524
+ if (isErrorResult (addConformanceRequirement (resolvedSubject, protoDecl,
4525
+ source)))
4526
+ anyErrors = true ;
4527
+
4528
+ auto *assocType = paramProtoType->getAssocType ();
4529
+ auto depType = DependentMemberType::get (
4530
+ resolvedSubject.getDependentType (*this ), assocType);
4531
+ if (isErrorResult (addSameTypeRequirement (Type (depType),
4532
+ paramProtoType->getArgumentType (),
4533
+ source,
4534
+ UnresolvedHandlingKind::GenerateConstraints)))
4535
+ anyErrors = true ;
4536
+
4537
+ return anyErrors ? ConstraintResult::Conflicting
4538
+ : ConstraintResult::Resolved;
4539
+
4517
4540
// Protocol requirements.
4518
- if (constraintType->isExistentialType ()) {
4541
+ } else if (constraintType->isExistentialType ()) {
4519
4542
bool anyErrors = false ;
4520
4543
auto layout = constraintType->getExistentialLayout ();
4521
4544
0 commit comments