mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Stop passing around a LazyResolver in name lookup
Note that in all cases it was either nullptr or ctx.getLazyResolver().
While passing in nullptr might appear at first glance to mean something
("don't type check anything"), in practice we would check for a nullptr
value and pull out ctx.getLazyResolver() instead. Furthermore, with
the lazy resolver going away (at least for resolveDeclSignature() calls),
it won't make sense to do that anymore anyway.
This commit is contained in:
@@ -54,7 +54,6 @@ class ModuleNameLookup {
|
||||
TinyPtrVector<ValueDecl *>, 32>;
|
||||
|
||||
ModuleLookupCache cache;
|
||||
LazyResolver * const typeResolver;
|
||||
const ResolutionKind resolutionKind;
|
||||
const bool respectAccessControl;
|
||||
|
||||
@@ -106,10 +105,9 @@ class ModuleNameLookup {
|
||||
ArrayRef<ModuleDecl::ImportedModule> extraImports);
|
||||
|
||||
public:
|
||||
ModuleNameLookup(LazyResolver *typeResolver, ModuleDecl *M,
|
||||
ResolutionKind resolutionKind)
|
||||
: typeResolver(typeResolver), resolutionKind(resolutionKind),
|
||||
respectAccessControl(!M->getASTContext().isAccessControlDisabled()) {}
|
||||
ModuleNameLookup(ASTContext &ctx, ResolutionKind resolutionKind)
|
||||
: resolutionKind(resolutionKind),
|
||||
respectAccessControl(!ctx.isAccessControlDisabled()) {}
|
||||
|
||||
/// Performs a qualified lookup into the given module and, if necessary, its
|
||||
/// reexports, observing proper shadowing rules.
|
||||
@@ -133,9 +131,9 @@ class LookupByName : public ModuleNameLookup<LookupByName> {
|
||||
const NLKind lookupKind;
|
||||
|
||||
public:
|
||||
LookupByName(LazyResolver *typeResolver, ModuleDecl *M,
|
||||
ResolutionKind resolutionKind, DeclName name, NLKind lookupKind)
|
||||
: Super(typeResolver, M, resolutionKind), name(name),
|
||||
LookupByName(ASTContext &ctx, ResolutionKind resolutionKind,
|
||||
DeclName name, NLKind lookupKind)
|
||||
: Super(ctx, resolutionKind), name(name),
|
||||
lookupKind(lookupKind) {}
|
||||
|
||||
private:
|
||||
@@ -194,9 +192,9 @@ class LookupVisibleDecls : public ModuleNameLookup<LookupVisibleDecls> {
|
||||
const NLKind lookupKind;
|
||||
|
||||
public:
|
||||
LookupVisibleDecls(LazyResolver *typeResolver, ModuleDecl *M,
|
||||
ResolutionKind resolutionKind, NLKind lookupKind)
|
||||
: ModuleNameLookup(typeResolver, M, resolutionKind),
|
||||
LookupVisibleDecls(ASTContext &ctx, ResolutionKind resolutionKind,
|
||||
NLKind lookupKind)
|
||||
: ModuleNameLookup(ctx, resolutionKind),
|
||||
lookupKind(lookupKind) {}
|
||||
|
||||
private:
|
||||
@@ -276,7 +274,7 @@ bool ModuleNameLookup<LookupStrategy>::recordImportDecls(
|
||||
llvm::copy_if(newDecls, std::back_inserter(results),
|
||||
[&](ValueDecl *result) -> bool {
|
||||
if (!result->hasInterfaceType()) {
|
||||
if (typeResolver) {
|
||||
if (auto *typeResolver = result->getASTContext().getLazyResolver()) {
|
||||
typeResolver->resolveDeclSignature(result);
|
||||
if (result->isInvalid())
|
||||
return true;
|
||||
@@ -451,18 +449,17 @@ void namelookup::lookupInModule(ModuleDecl *startModule,
|
||||
SmallVectorImpl<ValueDecl *> &decls,
|
||||
NLKind lookupKind,
|
||||
ResolutionKind resolutionKind,
|
||||
LazyResolver *typeResolver,
|
||||
const DeclContext *moduleScopeContext,
|
||||
ArrayRef<ModuleDecl::ImportedModule> extraImports) {
|
||||
auto *stats = startModule->getASTContext().Stats;
|
||||
auto &ctx = startModule->getASTContext();
|
||||
auto *stats = ctx.Stats;
|
||||
if (stats)
|
||||
stats->getFrontendCounters().NumLookupInModule++;
|
||||
|
||||
FrontendStatsTracer tracer(stats, "lookup-in-module");
|
||||
|
||||
assert(moduleScopeContext && moduleScopeContext->isModuleScopeContext());
|
||||
LookupByName lookup(typeResolver, startModule, resolutionKind, name,
|
||||
lookupKind);
|
||||
LookupByName lookup(ctx, resolutionKind, name, lookupKind);
|
||||
lookup.lookupInModule(decls, startModule, topAccessPath, moduleScopeContext,
|
||||
extraImports);
|
||||
}
|
||||
@@ -473,11 +470,11 @@ void namelookup::lookupVisibleDeclsInModule(
|
||||
SmallVectorImpl<ValueDecl *> &decls,
|
||||
NLKind lookupKind,
|
||||
ResolutionKind resolutionKind,
|
||||
LazyResolver *typeResolver,
|
||||
const DeclContext *moduleScopeContext,
|
||||
ArrayRef<ModuleDecl::ImportedModule> extraImports) {
|
||||
auto &ctx = M->getASTContext();
|
||||
assert(moduleScopeContext && moduleScopeContext->isModuleScopeContext());
|
||||
LookupVisibleDecls lookup(typeResolver, M, resolutionKind, lookupKind);
|
||||
LookupVisibleDecls lookup(ctx, resolutionKind, lookupKind);
|
||||
lookup.lookupInModule(decls, M, accessPath, moduleScopeContext, extraImports);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user