@@ -2301,6 +2301,18 @@ bool CompletionLookup::tryTupleExprCompletions(Type ExprType) {
23012301 return true ;
23022302}
23032303
2304+ void CompletionLookup::tryFunctionIsolationCompletion (Type ExprType) {
2305+ auto *FT = ExprType->getAs <FunctionType>();
2306+ if (!FT || !FT->getIsolation ().isErased ())
2307+ return ;
2308+
2309+ // The type of `.isolation` is `(any Actor)?`
2310+ auto *actorProto = Ctx.getProtocol (KnownProtocolKind::Actor);
2311+ auto memberTy = OptionalType::get (actorProto->getDeclaredExistentialType ());
2312+
2313+ addBuiltinMemberRef (Ctx.Id_isolation .str (), memberTy);
2314+ }
2315+
23042316bool CompletionLookup::tryFunctionCallCompletions (
23052317 Type ExprType, const ValueDecl *VD,
23062318 std::optional<SemanticContextKind> SemanticContext) {
@@ -2378,6 +2390,9 @@ bool CompletionLookup::tryUnwrappedCompletions(Type ExprType, bool isIUO) {
23782390 }
23792391 if (NumBytesToEraseForOptionalUnwrap <=
23802392 CodeCompletionResult::MaxNumBytesToErase) {
2393+ // Add '.isolation' to @isolated(any) functions.
2394+ tryFunctionIsolationCompletion (Unwrapped);
2395+
23812396 if (!tryTupleExprCompletions (Unwrapped)) {
23822397 lookupVisibleMemberDecls (*this , Unwrapped, DotLoc,
23832398 CurrDeclContext,
@@ -2453,6 +2468,10 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD,
24532468 ExprType = OptionalType::get (ExprType);
24542469
24552470 // Handle special cases
2471+
2472+ // Add '.isolation' to @isolated(any) functions.
2473+ tryFunctionIsolationCompletion (ExprType);
2474+
24562475 bool isIUO = VD && VD->isImplicitlyUnwrappedOptional ();
24572476 if (tryFunctionCallCompletions (ExprType, IsDeclUnapplied ? VD : nullptr ))
24582477 return ;
0 commit comments