Skip to content

Commit 43b7493

Browse files
committed
AST: Refactor ParameterizedProtocolType::getRequirements()
1 parent 508dacc commit 43b7493

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/AST/Type.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3747,12 +3747,16 @@ void ParameterizedProtocolType::getRequirements(
37473747
assert(argTypes.size() <= assocTypes.size());
37483748

37493749
auto conformance = lookupConformance(baseType, protoDecl);
3750+
auto subMap = SubstitutionMap::getProtocolSubstitutions(
3751+
protoDecl, baseType, conformance);
37503752

37513753
for (unsigned i : indices(argTypes)) {
37523754
auto argType = argTypes[i];
37533755
auto *assocType = assocTypes[i];
3754-
auto subjectType = conformance.getAssociatedType(
3755-
baseType, assocType->getDeclaredInterfaceType());
3756+
// Do a general type substitution here because the associated type might be
3757+
// from an inherited protocol, in which case we will evaluate a non-trivial
3758+
// conformance path.
3759+
auto subjectType = assocType->getDeclaredInterfaceType().subst(subMap);
37563760
reqs.emplace_back(RequirementKind::SameType, subjectType, argType);
37573761
}
37583762
}

0 commit comments

Comments
 (0)