[AST] Use declaration-based name lookup in the conformance lookup table.

This avoids a call into the lazy resolver simply to figure out which
protocols a type conforms to.
This commit is contained in:
Doug Gregor
2018-08-06 23:40:47 -07:00
parent a1fe426866
commit cc9ac43f22
3 changed files with 8 additions and 36 deletions

View File

@@ -175,8 +175,6 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
return;
// Handle the extensions that we have not yet visited.
llvm::SetVector<ExtensionDecl *> &delayedExtensionDecls
= DelayedExtensionDecls[static_cast<unsigned>(stage)];
nominal->prepareExtensions();
while (auto next = lastProcessed.getPointer()
? lastProcessed.getPointer()->NextExtension.getPointer()
@@ -196,36 +194,16 @@ void ConformanceLookupTable::forEachInStage(ConformanceStage stage,
protocols.push_back({SourceLoc(), conf->getProtocol()});
}
} else if (next->getParentSourceFile()) {
if (!resolver) {
// We have a parsed extension that we can't resolve well enough to
// get any information from. Queue it for later.
// FIXME: Per the comment on DelayedExtensionDecls, this is insane.
delayedExtensionDecls.insert(next);
continue;
bool anyObject = false;
for (const auto &found :
getDirectlyInheritedNominalTypeDecls(next, anyObject)) {
if (auto proto = dyn_cast<ProtocolDecl>(found.second))
protocols.push_back({found.first, proto});
}
// Resolve this extension.
delayedExtensionDecls.remove(next);
resolver->resolveExtensionForConformanceConstruction(next, protocols);
}
extensionFunc(next, protocols);
}
// If we delayed any extension declarations because we didn't have a resolver
// then, but we have a resolver now, process them.
if (resolver) {
while (!delayedExtensionDecls.empty()) {
// Remove the last extension declaration.
auto ext = delayedExtensionDecls.back();
delayedExtensionDecls.remove(ext);
SmallVector<LazyResolver::ConformanceConstructionInfo, 2> protocols;
resolver->resolveExtensionForConformanceConstruction(ext, protocols);
extensionFunc(ext, protocols);
}
}
}
void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,