[CodeCompletion] Compute InvalidAsyncContext warning when making a completion result contextual

Store whether a result is async in the `ContextFreeCodeCompletionResult` and determine whether an async method is used in a sync context when promoting the context free result to a contextual result.

rdar://78317170
This commit is contained in:
Alex Hoppen
2022-07-21 14:27:19 +02:00
parent 9fc850abed
commit dec32674ef
15 changed files with 135 additions and 77 deletions

View File

@@ -910,6 +910,7 @@ static void transformAndForwardResults(
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
innerSink.swiftSink, CodeCompletionResultKind::BuiltinOperator,
completionString, CodeCompletionOperatorKind::None,
/*IsAsync=*/false,
/*BriefDocComment=*/"", CodeCompletionResultType::notApplicable(),
ContextFreeNotRecommendedReason::None,
CodeCompletionDiagnosticSeverity::None,
@@ -919,6 +920,7 @@ static void transformAndForwardResults(
CodeCompletionFlairBit::ExpressionSpecific,
exactMatch ? exactMatch->getNumBytesToErase() : 0,
/*TypeContext=*/nullptr, /*DC=*/nullptr, /*USRTypeContext=*/nullptr,
/*CanCurrDeclContextHandleAsync=*/false,
ContextualNotRecommendedReason::None);
SwiftCompletionInfo info;