mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
RequirementMachine: Split up list of associated types in ProtocolGraph
Store the protocol's direct associated types separately from the inherited associated types, since in a couple of places we only need the direct associated types. Also, factor out a new ProtocolGraph::compute() method that does all the steps in the right order.
This commit is contained in:
@@ -86,21 +86,21 @@ void RewriteSystemBuilder::addGenericSignature(CanGenericSignature sig) {
|
||||
// Collect all protocols transitively referenced from the generic signature's
|
||||
// requirements.
|
||||
Protocols.visitRequirements(sig->getRequirements());
|
||||
Protocols.computeTransitiveClosure();
|
||||
Protocols.computeLinearOrder();
|
||||
Protocols.computeInheritedProtocols();
|
||||
Protocols.computeInheritedAssociatedTypes();
|
||||
Protocols.compute();
|
||||
|
||||
// Add rewrite rules for each protocol.
|
||||
for (auto *proto : Protocols.Protocols) {
|
||||
for (auto *proto : Protocols.getProtocols()) {
|
||||
if (Debug) {
|
||||
llvm::dbgs() << "protocol " << proto->getName() << " {\n";
|
||||
}
|
||||
|
||||
const auto &info = Protocols.getProtocolInfo(proto);
|
||||
|
||||
for (auto *type : info.AssociatedTypes)
|
||||
addAssociatedType(type, proto);
|
||||
for (auto *assocType : info.AssociatedTypes)
|
||||
addAssociatedType(assocType, proto);
|
||||
|
||||
for (auto *assocType : info.InheritedAssociatedTypes)
|
||||
addAssociatedType(assocType, proto);
|
||||
|
||||
for (auto req : info.Requirements)
|
||||
addRequirement(req.getCanonical(), proto);
|
||||
|
||||
Reference in New Issue
Block a user