mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -134,15 +134,16 @@ bool SourceKit::CodeCompletion::addCustomCompletions(
|
||||
auto *contextFreeResult =
|
||||
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
|
||||
sink.swiftSink, CodeCompletionResultKind::Pattern, completionString,
|
||||
CodeCompletionOperatorKind::None, /*BriefDocComment=*/"",
|
||||
CodeCompletionResultType::unknown(),
|
||||
CodeCompletionOperatorKind::None, /*IsAsync=*/false,
|
||||
/*BriefDocComment=*/"", CodeCompletionResultType::unknown(),
|
||||
ContextFreeNotRecommendedReason::None,
|
||||
CodeCompletionDiagnosticSeverity::None, /*DiagnosticMessage=*/"");
|
||||
auto *swiftResult = new (sink.allocator) CodeCompletion::SwiftResult(
|
||||
*contextFreeResult, SemanticContextKind::Local,
|
||||
CodeCompletionFlairBit::ExpressionSpecific,
|
||||
/*NumBytesToErase=*/0, /*TypeContext=*/nullptr, /*DC=*/nullptr,
|
||||
/*USRTypeContext=*/nullptr, ContextualNotRecommendedReason::None);
|
||||
/*USRTypeContext=*/nullptr, /*CanCurrDeclContextHandleAsync=*/false,
|
||||
ContextualNotRecommendedReason::None);
|
||||
|
||||
CompletionBuilder builder(sink, *swiftResult);
|
||||
builder.setCustomKind(customCompletion.Kind);
|
||||
@@ -1165,8 +1166,8 @@ Completion *CompletionBuilder::finish() {
|
||||
new (sink.allocator) ContextFreeCodeCompletionResult(
|
||||
contextFreeBase.getKind(),
|
||||
contextFreeBase.getOpaqueAssociatedKind(), opKind,
|
||||
contextFreeBase.isSystem(), newCompletionString,
|
||||
contextFreeBase.getModuleName(),
|
||||
contextFreeBase.isSystem(), contextFreeBase.isAsync(),
|
||||
newCompletionString, contextFreeBase.getModuleName(),
|
||||
contextFreeBase.getBriefDocComment(),
|
||||
contextFreeBase.getAssociatedUSRs(),
|
||||
contextFreeBase.getResultType(),
|
||||
|
||||
Reference in New Issue
Block a user