Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions include/swift/AST/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,9 @@ class ModuleDecl
void lookupTopLevelDeclsByObjCName(SmallVectorImpl<Decl *> &Results,
DeclName name);

/// This is a hack for 'main' file parsing and the integrated REPL.
///
/// FIXME: Refactor main file parsing to not pump the parser incrementally.
/// FIXME: Remove the integrated REPL.
void clearLookupCache();
/// This is a hack for SynthesizedFileUnit and code completion. Do not add new
/// uses of it.
void clearLookupCache(bool includingImports = true);

/// Finds all class members defined in this module.
///
Expand Down
7 changes: 5 additions & 2 deletions lib/AST/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3239,8 +3239,9 @@ bool SourceFile::shouldCrossImport() const {
getASTContext().LangOpts.EnableCrossImportOverlays;
}

void ModuleDecl::clearLookupCache() {
getASTContext().getImportCache().clear();
void ModuleDecl::clearLookupCache(bool includingImports) {
if (includingImports)
getASTContext().getImportCache().clear();

setIsObjCNameLookupCachePopulated(false);
ObjCNameLookupCache.clear();
Expand Down Expand Up @@ -3495,6 +3496,8 @@ void SourceFile::addTopLevelDecl(Decl *d) {
auto &ctx = getASTContext();
auto *mutableThis = const_cast<SourceFile *>(this);
ctx.evaluator.clearCachedOutput(ParseTopLevelDeclsRequest{mutableThis});

getParentModule()->clearLookupCache(/*includingImports*/isa<ImportDecl>(d));
}

void SourceFile::prependTopLevelDecl(Decl *d) {
Expand Down
9 changes: 9 additions & 0 deletions test/IDE/pr83369.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %batch-code-completion -module-name main

extension Int {}

// Make sure we can resolve P here.
protocol P<X> where X: main.#^COMPLETE^# {
associatedtype X
}
// COMPLETE: Decl[Protocol]/CurrModule: P[#P#]; name=P