Skip to content

Commit 39d633f

Browse files
committed
[CodeCompletion] Remove unused 'isAsync' flag from CodeCompletionResult
1 parent 9a6770e commit 39d633f

9 files changed

+16
-42
lines changed

Diff for: include/swift/AST/DiagnosticsIDE.def

-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
//===----------------------------------------------------------------------===//
1717

18-
ERROR(ide_async_in_nonasync_context, none,
19-
"async %0 used in a context that does not support concurrency",
20-
(StringRef))
21-
2218
// NOTE: This is WARNING because this is emitted for cross actor references with
2319
// non-'Sendable' types. That is optionally ('-warn-concurrency') warning in
2420
// Swift 5.5.

Diff for: include/swift/IDE/CodeCompletionResult.h

+4-9
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ class ContextFreeCodeCompletionResult {
371371
CodeCompletionMacroRoles MacroRoles;
372372

373373
bool IsSystem : 1;
374-
bool IsAsync : 1;
375374
/// Whether the result has been annotated as having an async alternative that
376375
/// should be preferred in async contexts.
377376
bool HasAsyncAlternative : 1;
@@ -406,7 +405,7 @@ class ContextFreeCodeCompletionResult {
406405
ContextFreeCodeCompletionResult(
407406
CodeCompletionResultKind Kind, uint8_t AssociatedKind,
408407
CodeCompletionOperatorKind KnownOperatorKind,
409-
CodeCompletionMacroRoles MacroRoles, bool IsSystem, bool IsAsync,
408+
CodeCompletionMacroRoles MacroRoles, bool IsSystem,
410409
bool HasAsyncAlternative, CodeCompletionString *CompletionString,
411410
NullTerminatedStringRef ModuleName,
412411
NullTerminatedStringRef BriefDocComment,
@@ -418,7 +417,7 @@ class ContextFreeCodeCompletionResult {
418417
NullTerminatedStringRef FilterName,
419418
NullTerminatedStringRef NameForDiagnostics)
420419
: Kind(Kind), KnownOperatorKind(KnownOperatorKind),
421-
MacroRoles(MacroRoles), IsSystem(IsSystem), IsAsync(IsAsync),
420+
MacroRoles(MacroRoles), IsSystem(IsSystem),
422421
HasAsyncAlternative(HasAsyncAlternative),
423422
CompletionString(CompletionString), ModuleName(ModuleName),
424423
BriefDocComment(BriefDocComment), AssociatedUSRs(AssociatedUSRs),
@@ -435,8 +434,6 @@ class ContextFreeCodeCompletionResult {
435434
"Completion item should have diagnostic message iff the diagnostics "
436435
"severity is not none");
437436
assert(CompletionString && "Result should have a completion string");
438-
assert(!(HasAsyncAlternative && IsAsync) &&
439-
"A function shouldn't be both async and have an async alternative");
440437
if (isOperator() && KnownOperatorKind == CodeCompletionOperatorKind::None) {
441438
this->KnownOperatorKind = getCodeCompletionOperatorKind(CompletionString);
442439
}
@@ -453,7 +450,7 @@ class ContextFreeCodeCompletionResult {
453450
static ContextFreeCodeCompletionResult *createPatternOrBuiltInOperatorResult(
454451
CodeCompletionResultSink &Sink, CodeCompletionResultKind Kind,
455452
CodeCompletionString *CompletionString,
456-
CodeCompletionOperatorKind KnownOperatorKind, bool IsAsync,
453+
CodeCompletionOperatorKind KnownOperatorKin,
457454
NullTerminatedStringRef BriefDocComment,
458455
CodeCompletionResultType ResultType,
459456
ContextFreeNotRecommendedReason NotRecommended,
@@ -491,7 +488,7 @@ class ContextFreeCodeCompletionResult {
491488
static ContextFreeCodeCompletionResult *
492489
createDeclResult(CodeCompletionResultSink &Sink,
493490
CodeCompletionString *CompletionString,
494-
const Decl *AssociatedDecl, bool IsAsync,
491+
const Decl *AssociatedDecl,
495492
bool HasAsyncAlternative, NullTerminatedStringRef ModuleName,
496493
NullTerminatedStringRef BriefDocComment,
497494
ArrayRef<NullTerminatedStringRef> AssociatedUSRs,
@@ -530,8 +527,6 @@ class ContextFreeCodeCompletionResult {
530527

531528
bool isSystem() const { return IsSystem; };
532529

533-
bool isAsync() const { return IsAsync; };
534-
535530
bool hasAsyncAlternative() const { return HasAsyncAlternative; };
536531

537532
CodeCompletionString *getCompletionString() const { return CompletionString; }

Diff for: lib/IDE/CodeCompletionCache.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ static bool readCachedModule(llvm::MemoryBuffer *in,
236236
auto diagSeverity =
237237
static_cast<CodeCompletionDiagnosticSeverity>(*cursor++);
238238
auto isSystem = static_cast<bool>(*cursor++);
239-
auto isAsync = static_cast<bool>(*cursor++);
240239
auto hasAsyncAlternative = static_cast<bool>(*cursor++);
241240
auto chunkIndex = read32le(cursor);
242241
auto moduleIndex = read32le(cursor);
@@ -267,8 +266,8 @@ static bool readCachedModule(llvm::MemoryBuffer *in,
267266

268267
ContextFreeCodeCompletionResult *result =
269268
new (*V.Allocator) ContextFreeCodeCompletionResult(
270-
kind, associatedKind, opKind, roles, isSystem, isAsync,
271-
hasAsyncAlternative, string, moduleName, briefDocComment,
269+
kind, associatedKind, opKind, roles, isSystem,
270+
hasAsyncAlternative, string, moduleName, briefDocComment,
272271
llvm::ArrayRef(assocUSRs).copy(*V.Allocator),
273272
CodeCompletionResultType(resultTypes), notRecommended, diagSeverity,
274273
diagMessage, filterName, nameForDiagnostics);
@@ -428,7 +427,6 @@ static void writeCachedModule(llvm::raw_ostream &out,
428427
LE.write(static_cast<uint8_t>(R->getNotRecommendedReason()));
429428
LE.write(static_cast<uint8_t>(R->getDiagnosticSeverity()));
430429
LE.write(static_cast<uint8_t>(R->isSystem()));
431-
LE.write(static_cast<uint8_t>(R->isAsync()));
432430
LE.write(static_cast<uint8_t>(R->hasAsyncAlternative()));
433431
LE.write(
434432
static_cast<uint32_t>(addCompletionString(R->getCompletionString())));

Diff for: lib/IDE/CodeCompletionResult.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ ContextFreeCodeCompletionResult *
121121
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
122122
CodeCompletionResultSink &Sink, CodeCompletionResultKind Kind,
123123
CodeCompletionString *CompletionString,
124-
CodeCompletionOperatorKind KnownOperatorKind, bool IsAsync,
125-
NullTerminatedStringRef BriefDocComment,
124+
CodeCompletionOperatorKind KnownOperatorKind, NullTerminatedStringRef BriefDocComment,
126125
CodeCompletionResultType ResultType,
127126
ContextFreeNotRecommendedReason NotRecommended,
128127
CodeCompletionDiagnosticSeverity DiagnosticSeverity,
@@ -138,7 +137,7 @@ ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
138137
}
139138
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
140139
Kind, /*AssociatedKind=*/0, KnownOperatorKind, /*MacroRoles=*/{},
141-
/*IsSystem=*/false, IsAsync, /*HasAsyncAlternative=*/false,
140+
/*IsSystem=*/false, /*HasAsyncAlternative=*/false,
142141
CompletionString,
143142
/*ModuleName=*/"", BriefDocComment,
144143
/*AssociatedUSRs=*/{}, ResultType, NotRecommended, DiagnosticSeverity,
@@ -159,8 +158,7 @@ ContextFreeCodeCompletionResult::createKeywordResult(
159158
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
160159
CodeCompletionResultKind::Keyword, static_cast<uint8_t>(Kind),
161160
CodeCompletionOperatorKind::None, /*MacroRoles=*/{},
162-
/*IsSystem=*/false, /*IsAsync=*/false,
163-
/*HasAsyncAlternative=*/false, CompletionString,
161+
/*IsSystem=*/false, /*HasAsyncAlternative=*/false, CompletionString,
164162
/*ModuleName=*/"", BriefDocComment,
165163
/*AssociatedUSRs=*/{}, ResultType, ContextFreeNotRecommendedReason::None,
166164
CodeCompletionDiagnosticSeverity::None, /*DiagnosticMessage=*/"",
@@ -179,7 +177,7 @@ ContextFreeCodeCompletionResult::createLiteralResult(
179177
return new (Sink.getAllocator()) ContextFreeCodeCompletionResult(
180178
CodeCompletionResultKind::Literal, static_cast<uint8_t>(LiteralKind),
181179
CodeCompletionOperatorKind::None, /*MacroRoles=*/{},
182-
/*IsSystem=*/false, /*IsAsync=*/false, /*HasAsyncAlternative=*/false,
180+
/*IsSystem=*/false, /*HasAsyncAlternative=*/false,
183181
CompletionString,
184182
/*ModuleName=*/"",
185183
/*BriefDocComment=*/"",
@@ -207,7 +205,7 @@ getDeclNameForDiagnostics(const Decl *D, CodeCompletionResultSink &Sink) {
207205
ContextFreeCodeCompletionResult *
208206
ContextFreeCodeCompletionResult::createDeclResult(
209207
CodeCompletionResultSink &Sink, CodeCompletionString *CompletionString,
210-
const Decl *AssociatedDecl, bool IsAsync, bool HasAsyncAlternative,
208+
const Decl *AssociatedDecl, bool HasAsyncAlternative,
211209
NullTerminatedStringRef ModuleName, NullTerminatedStringRef BriefDocComment,
212210
ArrayRef<NullTerminatedStringRef> AssociatedUSRs,
213211
CodeCompletionResultType ResultType,
@@ -222,7 +220,7 @@ ContextFreeCodeCompletionResult::createDeclResult(
222220
CodeCompletionResultKind::Declaration,
223221
static_cast<uint8_t>(getCodeCompletionDeclKind(AssociatedDecl)),
224222
CodeCompletionOperatorKind::None, getCompletionMacroRoles(AssociatedDecl),
225-
getDeclIsSystem(AssociatedDecl), IsAsync, HasAsyncAlternative,
223+
getDeclIsSystem(AssociatedDecl), HasAsyncAlternative,
226224
CompletionString, ModuleName, BriefDocComment, AssociatedUSRs, ResultType,
227225
NotRecommended, DiagnosticSeverity, DiagnosticMessage,
228226
getCodeCompletionResultFilterName(CompletionString, Sink.getAllocator()),

Diff for: lib/IDE/CodeCompletionResultBuilder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ CodeCompletionResult *CodeCompletionResultBuilder::takeResult() {
128128
}
129129

130130
ContextFreeResult = ContextFreeCodeCompletionResult::createDeclResult(
131-
Sink, CCS, AssociatedDecl, IsAsync, HasAsyncAlternative, ModuleName,
131+
Sink, CCS, AssociatedDecl, HasAsyncAlternative, ModuleName,
132132
NullTerminatedStringRef(BriefDocComment, Allocator),
133133
copyAssociatedUSRs(Allocator, AssociatedDecl), ResultType,
134134
ContextFreeNotRecReason, ContextFreeDiagnosticSeverity,
@@ -145,7 +145,7 @@ CodeCompletionResult *CodeCompletionResultBuilder::takeResult() {
145145
case CodeCompletionResultKind::Pattern:
146146
ContextFreeResult =
147147
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
148-
Sink, Kind, CCS, CodeCompletionOperatorKind::None, IsAsync,
148+
Sink, Kind, CCS, CodeCompletionOperatorKind::None,
149149
NullTerminatedStringRef(BriefDocComment, Allocator), ResultType,
150150
ContextFreeNotRecReason, ContextFreeDiagnosticSeverity,
151151
ContextFreeDiagnosticMessage);

Diff for: lib/IDE/CodeCompletionResultBuilder.h

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class CodeCompletionResultBuilder {
4343
CodeCompletionFlair Flair;
4444
unsigned NumBytesToErase = 0;
4545
const Decl *AssociatedDecl = nullptr;
46-
bool IsAsync = false;
4746
bool HasAsyncAlternative = false;
4847
std::optional<CodeCompletionLiteralKind> LiteralKind;
4948
CodeCompletionKeywordKind KeywordKind = CodeCompletionKeywordKind::None;
@@ -116,7 +115,6 @@ class CodeCompletionResultBuilder {
116115

117116
void setAssociatedDecl(const Decl *D);
118117

119-
void setIsAsync(bool IsAsync) { this->IsAsync = IsAsync; }
120118
void setHasAsyncAlternative(bool HasAsyncAlternative) {
121119
this->HasAsyncAlternative = HasAsyncAlternative;
122120
}

Diff for: lib/IDE/CompletionLookup.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -864,14 +864,9 @@ void CompletionLookup::addVarDeclRef(const VarDecl *VD,
864864
}
865865
bool implicitlyAsync = false;
866866
analyzeActorIsolation(VD, VarType, implicitlyAsync, NotRecommended);
867-
bool explicitlyAsync = false;
868-
if (auto accessor = VD->getEffectfulGetAccessor()) {
869-
explicitlyAsync = accessor->hasAsync();
870-
}
871867
CodeCompletionResultBuilder Builder =
872868
makeResultBuilder(CodeCompletionResultKind::Declaration,
873869
getSemanticContext(VD, Reason, dynamicLookupInfo));
874-
Builder.setIsAsync(explicitlyAsync || implicitlyAsync);
875870
Builder.setCanCurrDeclContextHandleAsync(CanCurrDeclContextHandleAsync);
876871
Builder.setAssociatedDecl(VD);
877872
addLeadingDot(Builder);
@@ -1272,7 +1267,6 @@ void CompletionLookup::addFunctionCallPattern(
12721267
else
12731268
addTypeAnnotation(Builder, AFT->getResult(), genericSig);
12741269

1275-
Builder.setIsAsync(AFT->hasExtInfo() && AFT->isAsync());
12761270
Builder.setCanCurrDeclContextHandleAsync(CanCurrDeclContextHandleAsync);
12771271
};
12781272

@@ -1394,7 +1388,6 @@ void CompletionLookup::addMethodCall(const FuncDecl *FD,
13941388
CodeCompletionResultBuilder Builder =
13951389
makeResultBuilder(CodeCompletionResultKind::Declaration,
13961390
getSemanticContext(FD, Reason, dynamicLookupInfo));
1397-
Builder.setIsAsync(implictlyAsync || (AFT->hasExtInfo() && AFT->isAsync()));
13981391
Builder.setHasAsyncAlternative(
13991392
FD->getAsyncAlternative() &&
14001393
!FD->getAsyncAlternative()->shouldHideFromEditor());
@@ -1591,8 +1584,6 @@ void CompletionLookup::addConstructorCall(const ConstructorDecl *CD,
15911584
addTypeAnnotation(Builder, *Result, CD->getGenericSignatureOfContext());
15921585
}
15931586

1594-
Builder.setIsAsync(ConstructorType->hasExtInfo() &&
1595-
ConstructorType->isAsync());
15961587
Builder.setCanCurrDeclContextHandleAsync(CanCurrDeclContextHandleAsync);
15971588
};
15981589

@@ -1655,7 +1646,6 @@ void CompletionLookup::addSubscriptCall(const SubscriptDecl *SD,
16551646
CodeCompletionResultBuilder Builder =
16561647
makeResultBuilder(CodeCompletionResultKind::Declaration,
16571648
getSemanticContext(SD, Reason, dynamicLookupInfo));
1658-
Builder.setIsAsync(implictlyAsync);
16591649
Builder.setCanCurrDeclContextHandleAsync(CanCurrDeclContextHandleAsync);
16601650
Builder.setAssociatedDecl(SD);
16611651

Diff for: tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ bool SourceKit::CodeCompletion::addCustomCompletions(
135135
auto *contextFreeResult =
136136
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
137137
sink.swiftSink, CodeCompletionResultKind::Pattern, completionString,
138-
CodeCompletionOperatorKind::None, /*IsAsync=*/false,
138+
CodeCompletionOperatorKind::None,
139139
/*BriefDocComment=*/"", CodeCompletionResultType::unknown(),
140140
ContextFreeNotRecommendedReason::None,
141141
CodeCompletionDiagnosticSeverity::None, /*DiagnosticMessage=*/"");
@@ -1156,7 +1156,7 @@ Completion *CompletionBuilder::finish() {
11561156
contextFreeBase.getKind(),
11571157
contextFreeBase.getOpaqueAssociatedKind(), opKind,
11581158
contextFreeBase.getMacroRoles(), contextFreeBase.isSystem(),
1159-
contextFreeBase.isAsync(), contextFreeBase.hasAsyncAlternative(),
1159+
contextFreeBase.hasAsyncAlternative(),
11601160
newCompletionString, contextFreeBase.getModuleName(),
11611161
contextFreeBase.getBriefDocComment(),
11621162
contextFreeBase.getAssociatedUSRs(),

Diff for: tools/SourceKit/lib/SwiftLang/SwiftCompletion.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,6 @@ static void transformAndForwardResults(
909909
ContextFreeCodeCompletionResult::createPatternOrBuiltInOperatorResult(
910910
innerSink.swiftSink, CodeCompletionResultKind::BuiltinOperator,
911911
completionString, CodeCompletionOperatorKind::None,
912-
/*IsAsync=*/false,
913912
/*BriefDocComment=*/"", CodeCompletionResultType::notApplicable(),
914913
ContextFreeNotRecommendedReason::None,
915914
CodeCompletionDiagnosticSeverity::None,

0 commit comments

Comments
 (0)