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