@@ -31,18 +31,6 @@ class NominalTypeDecl;
3131class SubstitutionMap ;
3232class AbstractFunctionDecl ;
3333class AbstractClosureExpr ;
34- class ClosureActorIsolation ;
35-
36- // / Trampoline for AbstractClosureExpr::getActorIsolation.
37- ClosureActorIsolation
38- __AbstractClosureExpr_getActorIsolation (AbstractClosureExpr *CE);
39-
40- // / Returns a function reference to \c __AbstractClosureExpr_getActorIsolation.
41- // / This is needed so we can use it as a default argument for
42- // / \c getActorIsolationOfContext without knowing the layout of
43- // / \c ClosureActorIsolation.
44- llvm::function_ref<ClosureActorIsolation(AbstractClosureExpr *)>
45- _getRef__AbstractClosureExpr_getActorIsolation ();
4634
4735// / Determine whether the given types are (canonically) equal, declared here
4836// / to avoid having to include Types.h.
@@ -83,23 +71,28 @@ class ActorIsolation {
8371
8472private:
8573 union {
86- NominalTypeDecl *actor ;
74+ llvm::PointerUnion< NominalTypeDecl *, VarDecl *> actorInstance ;
8775 Type globalActor;
8876 void *pointer;
8977 };
9078 unsigned kind : 3 ;
9179 unsigned isolatedByPreconcurrency : 1 ;
9280 unsigned parameterIndex : 28 ;
9381
94- ActorIsolation (Kind kind, NominalTypeDecl *actor, unsigned parameterIndex)
95- : actor(actor), kind(kind), isolatedByPreconcurrency( false ),
96- parameterIndex (parameterIndex) { }
82+ ActorIsolation (Kind kind, NominalTypeDecl *actor, unsigned parameterIndex);
83+
84+ ActorIsolation (Kind kind, VarDecl *capturedActor);
9785
9886 ActorIsolation (Kind kind, Type globalActor)
9987 : globalActor(globalActor), kind(kind), isolatedByPreconcurrency(false ),
10088 parameterIndex (0 ) { }
10189
10290public:
91+ // No-argument constructor needed for DenseMap use in PostfixCompletion.cpp
92+ explicit ActorIsolation (Kind kind = Unspecified)
93+ : pointer(nullptr ), kind(kind), isolatedByPreconcurrency(false ),
94+ parameterIndex(0 ) { }
95+
10396 static ActorIsolation forUnspecified () {
10497 return ActorIsolation (Unspecified, nullptr );
10598 }
@@ -117,6 +110,10 @@ class ActorIsolation {
117110 return ActorIsolation (ActorInstance, actor, parameterIndex + 1 );
118111 }
119112
113+ static ActorIsolation forActorInstanceCapture (VarDecl *capturedActor) {
114+ return ActorIsolation (ActorInstance, capturedActor);
115+ }
116+
120117 static ActorIsolation forGlobalActor (Type globalActor, bool unsafe) {
121118 return ActorIsolation (
122119 unsafe ? GlobalActorUnsafe : GlobalActor, globalActor);
@@ -151,10 +148,9 @@ class ActorIsolation {
151148 }
152149 }
153150
154- NominalTypeDecl *getActor () const {
155- assert (getKind () == ActorInstance);
156- return actor;
157- }
151+ NominalTypeDecl *getActor () const ;
152+
153+ VarDecl *getActorInstance () const ;
158154
159155 bool isGlobalActor () const {
160156 return getKind () == GlobalActor || getKind () == GlobalActorUnsafe;
@@ -200,7 +196,8 @@ class ActorIsolation {
200196 return true ;
201197
202198 case ActorInstance:
203- return lhs.actor == rhs.actor && lhs.parameterIndex == rhs.parameterIndex ;
199+ return (lhs.getActor () == rhs.getActor () &&
200+ lhs.parameterIndex == rhs.parameterIndex );
204201
205202 case GlobalActor:
206203 case GlobalActorUnsafe:
@@ -223,16 +220,19 @@ class ActorIsolation {
223220// / Determine how the given value declaration is isolated.
224221ActorIsolation getActorIsolation (ValueDecl *value);
225222
223+ // / Trampoline for AbstractClosureExpr::getActorIsolation.
224+ ActorIsolation
225+ __AbstractClosureExpr_getActorIsolation (AbstractClosureExpr *CE);
226+
226227// / Determine how the given declaration context is isolated.
227228// / \p getClosureActorIsolation allows the specification of actor isolation for
228229// / closures that haven't been saved been saved to the AST yet. This is useful
229230// / for solver-based code completion which doesn't modify the AST but stores the
230231// / actor isolation of closures in the constraint system solution.
231232ActorIsolation getActorIsolationOfContext (
232233 DeclContext *dc,
233- llvm::function_ref<ClosureActorIsolation(AbstractClosureExpr *)>
234- getClosureActorIsolation =
235- _getRef__AbstractClosureExpr_getActorIsolation());
234+ llvm::function_ref<ActorIsolation(AbstractClosureExpr *)>
235+ getClosureActorIsolation = __AbstractClosureExpr_getActorIsolation);
236236
237237// / Check if both the value, and context are isolated to the same actor.
238238bool isSameActorIsolated (ValueDecl *value, DeclContext *dc);
@@ -256,9 +256,9 @@ bool usesFlowSensitiveIsolation(AbstractFunctionDecl const *fn);
256256// / \return true if it is safe to drop the global-actor qualifier.
257257bool safeToDropGlobalActor (
258258 DeclContext *dc, Type globalActor, Type ty,
259- llvm::function_ref<ClosureActorIsolation (AbstractClosureExpr *)>
259+ llvm::function_ref<ActorIsolation (AbstractClosureExpr *)>
260260 getClosureActorIsolation =
261- _getRef__AbstractClosureExpr_getActorIsolation() );
261+ __AbstractClosureExpr_getActorIsolation );
262262
263263void simple_display (llvm::raw_ostream &out, const ActorIsolation &state);
264264
0 commit comments