Skip to content

Commit c75337c

Browse files
committed
RequirementMachine: Remove lookupMemberType() in favor of existing substBaseType()
1 parent d7f8f20 commit c75337c

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

lib/AST/RequirementMachine/RequirementLowering.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -166,18 +166,6 @@ static void desugarLayoutRequirement(Type subjectType,
166166
result.emplace_back(RequirementKind::Layout, subjectType, layout);
167167
}
168168

169-
static Type lookupMemberType(Type subjectType, ProtocolDecl *protoDecl,
170-
AssociatedTypeDecl *assocType) {
171-
if (subjectType->isTypeParameter())
172-
return DependentMemberType::get(subjectType, assocType);
173-
174-
auto *M = protoDecl->getParentModule();
175-
auto conformance = M->lookupConformance(
176-
subjectType, protoDecl);
177-
return conformance.getAssociatedType(subjectType,
178-
assocType->getDeclaredInterfaceType());
179-
}
180-
181169
/// Desugar a protocol conformance requirement by splitting up protocol
182170
/// compositions on the right hand side into conformance and superclass
183171
/// requirements.
@@ -363,8 +351,9 @@ struct InferRequirementsWalker : public TypeWalker {
363351
};
364352
auto addSameTypeConstraint = [&](Type firstType,
365353
AssociatedTypeDecl *assocType) {
366-
auto *protocol = assocType->getProtocol();
367-
auto secondType = lookupMemberType(firstType, protocol, assocType);
354+
auto secondType = assocType->getDeclaredInterfaceType()
355+
->castTo<DependentMemberType>()
356+
->substBaseType(module, firstType);
368357
Requirement req(RequirementKind::SameType, firstType, secondType);
369358
desugarRequirement(req, reqs, errors);
370359
};

0 commit comments

Comments
 (0)