Excise the global TranslationUnit from TypeChecker.

Now that TypeChecker is being used to check all sorts of things (not all
from a single TU), it's not really correct to have a single top-level TU
that gets used everywhere. Instead, we should be using the TU that's
appropriate for whatever's being checked. This is a small correctness win
for order-independent type-checking, but is critical for multi-file
translation units, which is needed for implicit visibility.

This basically involves passing around DeclContexts much more.

Caveat: we aren't smart about, say, filtering extensions based on the
current context, so we're still not 100% correct here.

Swift SVN r9006
This commit is contained in:
Jordan Rose
2013-10-07 23:47:55 +00:00
parent 348ace2211
commit c2b00fc2d4
24 changed files with 541 additions and 409 deletions

View File

@@ -560,8 +560,8 @@ specializeTypeWitnesses(ASTContext &ctx,
/// Retrieve the explicit conformance of the given nominal type declaration
/// to the given protocol.
static std::tuple<NominalTypeDecl *, Decl *, ProtocolConformance *>
findExplicitConformance(Module *module, NominalTypeDecl *nominal,
ProtocolDecl *protocol, LazyResolver *resolver) {
findExplicitConformance(NominalTypeDecl *nominal, ProtocolDecl *protocol,
LazyResolver *resolver) {
// FIXME: Introduce a cache/lazy lookup structure to make this more efficient?
// Walk the nominal type, its extensions, superclasses, and so on.
@@ -726,7 +726,7 @@ LookupConformanceResult Module::lookupConformance(Type type,
Decl *declaresConformance = nullptr;
ProtocolConformance *nominalConformance = nullptr;
std::tie(owningNominal, declaresConformance, nominalConformance)
= findExplicitConformance(this, nominal, protocol, resolver);
= findExplicitConformance(nominal, protocol, resolver);
// If we didn't find an owning nominal, we don't conform. Cache the negative
// result and return.