@@ -2302,6 +2302,18 @@ bool CompletionLookup::tryTupleExprCompletions(Type ExprType) {
2302
2302
return true ;
2303
2303
}
2304
2304
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
+
2305
2317
bool CompletionLookup::tryFunctionCallCompletions (
2306
2318
Type ExprType, const ValueDecl *VD,
2307
2319
std::optional<SemanticContextKind> SemanticContext) {
@@ -2379,6 +2391,9 @@ bool CompletionLookup::tryUnwrappedCompletions(Type ExprType, bool isIUO) {
2379
2391
}
2380
2392
if (NumBytesToEraseForOptionalUnwrap <=
2381
2393
CodeCompletionResult::MaxNumBytesToErase) {
2394
+ // Add '.isolation' to @isolated(any) functions.
2395
+ tryFunctionIsolationCompletion (Unwrapped);
2396
+
2382
2397
if (!tryTupleExprCompletions (Unwrapped)) {
2383
2398
lookupVisibleMemberDecls (*this , Unwrapped, DotLoc,
2384
2399
CurrDeclContext,
@@ -2454,6 +2469,10 @@ void CompletionLookup::getValueExprCompletions(Type ExprType, ValueDecl *VD,
2454
2469
ExprType = OptionalType::get (ExprType);
2455
2470
2456
2471
// Handle special cases
2472
+
2473
+ // Add '.isolation' to @isolated(any) functions.
2474
+ tryFunctionIsolationCompletion (ExprType);
2475
+
2457
2476
bool isIUO = VD && VD->isImplicitlyUnwrappedOptional ();
2458
2477
if (tryFunctionCallCompletions (ExprType, IsDeclUnapplied ? VD : nullptr ))
2459
2478
return ;
0 commit comments