@@ -2785,6 +2785,25 @@ namespace {
2785
2785
}
2786
2786
}
2787
2787
return nullptr ;
2788
+ },
2789
+ [this ]() -> VarDecl * {
2790
+ auto isolation = getActorIsolationOfContext (
2791
+ const_cast <DeclContext *>(getDeclContext ()),
2792
+ getClosureActorIsolation);
2793
+ if (isolation == ActorIsolation::ActorInstance) {
2794
+ VarDecl *var = isolation.getActorInstance ();
2795
+ if (!var) {
2796
+ auto dc = const_cast <DeclContext *>(getDeclContext ());
2797
+ auto paramIdx = isolation.getActorInstanceParameter ();
2798
+ if (paramIdx == 0 ) {
2799
+ var = cast<AbstractFunctionDecl>(dc)->getImplicitSelfDecl ();
2800
+ } else {
2801
+ var = const_cast <ParamDecl *>(getParameterAt (dc, paramIdx - 1 ));
2802
+ }
2803
+ }
2804
+ return var;
2805
+ }
2806
+ return nullptr ;
2788
2807
});
2789
2808
}
2790
2809
@@ -3293,7 +3312,8 @@ namespace {
3293
3312
}
3294
3313
3295
3314
argForIsolatedParam = arg;
3296
- if (getIsolatedActor (arg))
3315
+ unsatisfiedIsolation = llvm::None;
3316
+ if (getIsolatedActor (arg) || isa<CurrentContextIsolationExpr>(arg))
3297
3317
continue ;
3298
3318
3299
3319
// An isolated parameter was provided with a non-isolated argument.
@@ -6030,7 +6050,8 @@ AbstractFunctionDecl const *swift::isActorInitOrDeInitContext(
6030
6050
// / for the given expression.
6031
6051
VarDecl *swift::getReferencedParamOrCapture (
6032
6052
Expr *expr,
6033
- llvm::function_ref<Expr *(OpaqueValueExpr *)> getExistentialValue) {
6053
+ llvm::function_ref<Expr *(OpaqueValueExpr *)> getExistentialValue,
6054
+ llvm::function_ref<VarDecl *()> getCurrentIsolatedVar) {
6034
6055
// Look through identity expressions and implicit conversions.
6035
6056
Expr *prior;
6036
6057
@@ -6057,6 +6078,11 @@ VarDecl *swift::getReferencedParamOrCapture(
6057
6078
if (auto declRef = dyn_cast<DeclRefExpr>(expr))
6058
6079
return dyn_cast<VarDecl>(declRef->getDecl ());
6059
6080
6081
+ // The current context isolation expression (#isolation) always
6082
+ // corresponds to the isolation of the given code.
6083
+ if (isa<CurrentContextIsolationExpr>(expr))
6084
+ return getCurrentIsolatedVar ();
6085
+
6060
6086
return nullptr ;
6061
6087
}
6062
6088
0 commit comments