@@ -4417,6 +4417,7 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44174417 }
44184418
44194419 static bool canUseAttributeOnDecl (DeclAttrKind DAK, bool IsInSil,
4420+ bool IsConcurrencyEnabled,
44204421 Optional<DeclKind> DK) {
44214422 if (DeclAttribute::isUserInaccessible (DAK))
44224423 return false ;
@@ -4426,6 +4427,8 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44264427 return false ;
44274428 if (!IsInSil && DeclAttribute::isSilOnly (DAK))
44284429 return false ;
4430+ if (!IsConcurrencyEnabled && DeclAttribute::isConcurrencyOnly (DAK))
4431+ return false ;
44294432 if (!DK.hasValue ())
44304433 return true ;
44314434 return DeclAttribute::canAttributeAppearOnDeclKind (DAK, DK.getValue ());
@@ -4443,9 +4446,10 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
44434446#include " swift/AST/DeclNodes.def"
44444447 }
44454448 }
4449+ bool IsConcurrencyEnabled = Ctx.LangOpts .EnableExperimentalConcurrency ;
44464450 std::string Description = TargetName.str () + " Attribute" ;
44474451#define DECL_ATTR (KEYWORD, NAME, ...) \
4448- if (canUseAttributeOnDecl (DAK_##NAME, IsInSil, DK)) \
4452+ if (canUseAttributeOnDecl (DAK_##NAME, IsInSil, IsConcurrencyEnabled, DK)) \
44494453 addDeclAttrKeyword (#KEYWORD, Description);
44504454#include " swift/AST/Attr.def"
44514455 }
@@ -5488,17 +5492,25 @@ addKeyword(CodeCompletionResultSink &Sink, StringRef Name,
54885492 Builder.setExpectedTypeRelation (TypeRelation);
54895493}
54905494
5491- static void addDeclKeywords (CodeCompletionResultSink &Sink) {
5495+ static void addDeclKeywords (CodeCompletionResultSink &Sink,
5496+ bool IsConcurrencyEnabled) {
54925497 auto AddDeclKeyword = [&](StringRef Name, CodeCompletionKeywordKind Kind,
54935498 Optional<DeclAttrKind> DAK) {
54945499 if (Name == " let" || Name == " var" ) {
54955500 // Treat keywords that could be the start of a pattern specially.
54965501 return ;
54975502 }
54985503
5504+ // FIXME: This should use canUseAttributeOnDecl.
5505+
54995506 // Remove user inaccessible keywords.
55005507 if (DAK.hasValue () && DeclAttribute::isUserInaccessible (*DAK)) return ;
55015508
5509+ // Remove keywords only available when concurrency is enabled.
5510+ if (DAK.hasValue () && !IsConcurrencyEnabled &&
5511+ DeclAttribute::isConcurrencyOnly (*DAK))
5512+ return ;
5513+
55025514 addKeyword (Sink, Name, Kind);
55035515 };
55045516
@@ -5611,7 +5623,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
56115623 LLVM_FALLTHROUGH;
56125624 }
56135625 case CompletionKind::StmtOrExpr:
5614- addDeclKeywords (Sink);
5626+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
56155627 addStmtKeywords (Sink, MaybeFuncBody);
56165628 LLVM_FALLTHROUGH;
56175629 case CompletionKind::ReturnStmtExpr:
@@ -5672,7 +5684,7 @@ void CodeCompletionCallbacksImpl::addKeywords(CodeCompletionResultSink &Sink,
56725684 .Default (false );
56735685 }) != ParsedKeywords.end ();
56745686 if (!HasDeclIntroducer) {
5675- addDeclKeywords (Sink);
5687+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
56765688 addLetVarKeywords (Sink);
56775689 }
56785690 break ;
@@ -6186,15 +6198,15 @@ void CodeCompletionCallbacksImpl::doneParsing() {
61866198
61876199 if (CurDeclContext->isTypeContext ()) {
61886200 // Override completion (CompletionKind::NominalMemberBeginning).
6189- addDeclKeywords (Sink);
6201+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
61906202 addLetVarKeywords (Sink);
61916203 SmallVector<StringRef, 0 > ParsedKeywords;
61926204 CompletionOverrideLookup OverrideLookup (Sink, Context, CurDeclContext,
61936205 ParsedKeywords, SourceLoc ());
61946206 OverrideLookup.getOverrideCompletions (SourceLoc ());
61956207 } else {
61966208 // Global completion (CompletionKind::PostfixExprBeginning).
6197- addDeclKeywords (Sink);
6209+ addDeclKeywords (Sink, Context. LangOpts . EnableExperimentalConcurrency );
61986210 addStmtKeywords (Sink, MaybeFuncBody);
61996211 addSuperKeyword (Sink);
62006212 addLetVarKeywords (Sink);
0 commit comments