[CodeCompletion] Don't check 'InvalidAsyncContext' for imported globals

'InvalidAsyncContext' depends on the decl context. That may case
"sticky" not-recommended If it's cached for a non-async context.

To workaround this, stop checking 'InvalidAsyncContext' when collecting
completion items for caching. Also consistently use the 'SourceFile' as
the decl context to avoid decl context specific behavior.

rdar://78315441
This commit is contained in:
Rintaro Ishizaki
2021-05-21 15:16:36 -07:00
parent 53264a64d9
commit 0ce1faa6c7
4 changed files with 95 additions and 7 deletions

View File

@@ -342,6 +342,10 @@ static void writeCachedModule(llvm::raw_ostream &out,
endian::Writer LE(results, little);
for (CodeCompletionResult *R : V.Sink.Results) {
assert(!R->isArgumentLabels() && "Argument labels should not be cached");
assert(R->getNotRecommendedReason() !=
CodeCompletionResult::NotRecommendedReason::InvalidAsyncContext &&
"InvalidAsyncContext is decl context specific, cannot be cached");
// FIXME: compress bitfield
LE.write(static_cast<uint8_t>(R->getKind()));
if (R->getKind() == CodeCompletionResult::Declaration)