Skip to content

Commit e99e2b3

Browse files
committed
GSB: Desugar ParametrizedProtocolType
1 parent a416116 commit e99e2b3

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4502,6 +4502,7 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
45024502
// Check whether we have a reasonable constraint type at all.
45034503
if (!constraintType->is<ProtocolType>() &&
45044504
!constraintType->is<ProtocolCompositionType>() &&
4505+
!constraintType->is<ParametrizedProtocolType>() &&
45054506
!constraintType->getClassOrBoundGenericClass()) {
45064507
if (source.getLoc().isValid() && !constraintType->hasError()) {
45074508
Impl->HadAnyError = true;
@@ -4514,8 +4515,30 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
45144515
return ConstraintResult::Conflicting;
45154516
}
45164517

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+
45174540
// Protocol requirements.
4518-
if (constraintType->isExistentialType()) {
4541+
} else if (constraintType->isExistentialType()) {
45194542
bool anyErrors = false;
45204543
auto layout = constraintType->getExistentialLayout();
45214544

0 commit comments

Comments
 (0)