@@ -86,19 +86,13 @@ class ActorIsolationRestriction {
86
86
// / the actor's isolation domain.
87
87
ActorSelf,
88
88
89
- // / References to a declaration that is part of a global actor are only
90
- // / permitted from other declarations with that same global actor.
89
+ // / References to a declaration that is part of a global actor are
90
+ // / permitted from other declarations with that same global actor or
91
+ // / are permitted from elsewhere as a cross-actor reference.
91
92
GlobalActor,
92
-
93
- // / References to this entity are allowed from anywhere, but doing so may
94
- // / cross an actor boundary if it is not from the same global actor.
95
- CrossGlobalActor,
96
93
};
97
94
98
95
private:
99
- // / The kind of restriction.
100
- Kind kind;
101
-
102
96
union {
103
97
// / The local context that an entity is tied to.
104
98
DeclContext *localContext;
@@ -110,9 +104,17 @@ class ActorIsolationRestriction {
110
104
TypeBase *globalActor;
111
105
} data;
112
106
113
- explicit ActorIsolationRestriction (Kind kind) : kind(kind) { }
107
+ explicit ActorIsolationRestriction (Kind kind, bool isCrossActor)
108
+ : kind(kind), isCrossActor(isCrossActor) { }
114
109
115
110
public:
111
+ // / The kind of restriction.
112
+ const Kind kind;
113
+
114
+ // / Whether referencing this from another actor constitutes a cross-acter
115
+ // / reference.
116
+ const bool isCrossActor;
117
+
116
118
Kind getKind () const { return kind; }
117
119
118
120
// / Retrieve the actor class that the declaration is within.
@@ -123,25 +125,26 @@ class ActorIsolationRestriction {
123
125
124
126
// / Retrieve the actor class that the declaration is within.
125
127
Type getGlobalActor () const {
126
- assert (kind == GlobalActor || kind == CrossGlobalActor );
128
+ assert (kind == GlobalActor);
127
129
return Type (data.globalActor );
128
130
}
129
131
130
132
// / There are no restrictions on the use of the entity.
131
133
static ActorIsolationRestriction forUnrestricted () {
132
- return ActorIsolationRestriction (Unrestricted);
134
+ return ActorIsolationRestriction (Unrestricted, /* isCrossActor= */ false );
133
135
}
134
136
135
137
// / Accesses to the given declaration are unsafe.
136
138
static ActorIsolationRestriction forUnsafe () {
137
- return ActorIsolationRestriction (Unsafe);
139
+ return ActorIsolationRestriction (Unsafe, /* isCrossActor= */ false );
138
140
}
139
141
140
142
// / Accesses to the given declaration can only be made via the 'self' of
141
143
// / the current actor or is a cross-actor access.
142
144
static ActorIsolationRestriction forActorSelf (
143
145
ClassDecl *actorClass, bool isCrossActor) {
144
- ActorIsolationRestriction result (isCrossActor? CrossActorSelf : ActorSelf);
146
+ ActorIsolationRestriction result (isCrossActor? CrossActorSelf : ActorSelf,
147
+ isCrossActor);
145
148
result.data .actorClass = actorClass;
146
149
return result;
147
150
}
@@ -150,8 +153,7 @@ class ActorIsolationRestriction {
150
153
// / global actor or is a cross-actor access.
151
154
static ActorIsolationRestriction forGlobalActor (
152
155
Type globalActor, bool isCrossActor) {
153
- ActorIsolationRestriction result (
154
- isCrossActor ? CrossGlobalActor : GlobalActor);
156
+ ActorIsolationRestriction result (GlobalActor, isCrossActor);
155
157
result.data .globalActor = globalActor.getPointer ();
156
158
return result;
157
159
}
0 commit comments