@@ -4428,6 +4428,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44284428 }
44294429
44304430 static bool canUseAttributeOnDecl (DeclAttrKind DAK, bool IsInSil,
4431+ bool IsConcurrencyEnabled,
44314432 Optional<DeclKind> DK) {
44324433 if (DeclAttribute::isUserInaccessible (DAK))
44334434 return false ;
@@ -4437,6 +4438,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44374438 return false ;
44384439 if (!IsInSil && DeclAttribute::isSilOnly (DAK))
44394440 return false ;
4441+ if (!IsConcurrencyEnabled && DeclAttribute::isConcurrencyOnly (DAK))
4442+ return false ;
44404443 if (!DK.hasValue ())
44414444 return true ;
44424445 return DeclAttribute::canAttributeAppearOnDeclKind (DAK, DK.getValue ());
@@ -4454,9 +4457,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44544457#include " swift/AST/DeclNodes.def"
44554458 }
44564459 }
4460+ bool IsConcurrencyEnabled = Ctx.LangOpts .EnableExperimentalConcurrency ;
44574461 std::string Description = TargetName.str () + " Attribute" ;
44584462#define DECL_ATTR (KEYWORD, NAME, ...) \
4459- if (canUseAttributeOnDecl (DAK_##NAME, IsInSil, DK)) \
4463+ if (canUseAttributeOnDecl (DAK_##NAME, IsInSil, IsConcurrencyEnabled, DK)) \
44604464 addDeclAttrKeyword (#KEYWORD, Description);
44614465#include " swift/AST/Attr.def"
44624466 }
@@ -5503,17 +5507,25 @@ addKeyword(CodeCompletionResultSink &Sink, StringRef Name,
55035507 Builder.setExpectedTypeRelation (TypeRelation);
55045508}
55055509
5506- static void addDeclKeywords (CodeCompletionResultSink &Sink) {
5510+ static void addDeclKeywords (CodeCompletionResultSink &Sink,
5511+ bool IsConcurrencyEnabled) {
55075512 auto AddDeclKeyword = [&](StringRef Name, CodeCompletionKeywordKind Kind,
55085513 Optional<DeclAttrKind> DAK) {
55095514 if (Name == " let" || Name == " var" ) {
55105515 // Treat keywords that could be the start of a pattern specially.
55115516 return ;
55125517 }
55135518
5519+ // FIXME: This should use canUseAttributeOnDecl.
5520+
55145521 // Remove user inaccessible keywords.
55155522 if (DAK.hasValue () && DeclAttribute::isUserInaccessible (*DAK)) return ;
55165523
5524+ // Remove keywords only available when concurrency is enabled.
5525+ if (DAK.hasValue () && !IsConcurrencyEnabled &&
5526+ DeclAttribute::isConcurrencyOnly (*DAK))
5527+ return ;
5528+
55175529 addKeyword (Sink, Name, Kind);
55185530 };
55195531
@@ -5626,7 +5638,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
56265638 LLVM_FALLTHROUGH;
56275639 }
56285640 case CompletionKind::StmtOrExpr:
5629- addDeclKeywords (Sink);
5641+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
56305642 addStmtKeywords (Sink, MaybeFuncBody);
56315643 LLVM_FALLTHROUGH;
56325644 case CompletionKind::ReturnStmtExpr:
@@ -5687,7 +5699,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
56875699 .Default (false );
56885700 }) != ParsedKeywords.end ();
56895701 if (!HasDeclIntroducer) {
5690- addDeclKeywords (Sink);
5702+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
56915703 addLetVarKeywords (Sink);
56925704 }
56935705 break ;
@@ -6384,15 +6396,15 @@ void CodeCompletionCallbacksImpl::doneParsing() {
63846396
63856397 if (CurDeclContext->isTypeContext ()) {
63866398 // Override completion (CompletionKind::NominalMemberBeginning).
6387- addDeclKeywords (Sink);
6399+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
63886400 addLetVarKeywords (Sink);
63896401 SmallVector<StringRef, 0 > ParsedKeywords;
63906402 CompletionOverrideLookup OverrideLookup (Sink, Context, CurDeclContext,
63916403 ParsedKeywords, SourceLoc ());
63926404 OverrideLookup.getOverrideCompletions (SourceLoc ());
63936405 } else {
63946406 // Global completion (CompletionKind::PostfixExprBeginning).
6395- addDeclKeywords (Sink);
6407+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
63966408 addStmtKeywords (Sink, MaybeFuncBody);
63976409 addSuperKeyword (Sink);
63986410 addLetVarKeywords (Sink);
0 commit comments