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