@@ -110,20 +110,19 @@ class SILIsolationInfo {
110
110
// clang-format off
111
111
std::variant<
112
112
// Used for actor isolated when we have ActorIsolation info from the AST.
113
- std::optional<ActorIsolation>,
114
- // Used for actor isolation when we infer the actor at the SIL level.
115
- NominalTypeDecl *,
113
+ ActorIsolation,
116
114
// The task isolated parameter when we find a task isolated value.
117
115
SILValue
118
116
> data;
119
117
// clang-format on
120
118
121
- SILIsolationInfo (Kind kind, std::optional<ActorIsolation> actorIsolation)
122
- : kind(kind), data(actorIsolation) {}
123
- SILIsolationInfo (Kind kind, NominalTypeDecl *decl) : kind(kind), data(decl) {}
119
+ SILIsolationInfo (ActorIsolation actorIsolation)
120
+ : kind(Actor), data(actorIsolation) {}
124
121
125
122
SILIsolationInfo (Kind kind, SILValue value) : kind(kind), data(value) {}
126
123
124
+ SILIsolationInfo (Kind kind) : kind(kind), data() {}
125
+
127
126
public:
128
127
SILIsolationInfo () : kind(Kind::Unknown), data() {}
129
128
@@ -146,18 +145,11 @@ class SILIsolationInfo {
146
145
147
146
void printForDiagnostics (llvm::raw_ostream &os) const ;
148
147
149
- std::optional< ActorIsolation> getActorIsolation () const {
148
+ ActorIsolation getActorIsolation () const {
150
149
assert (kind == Actor);
151
- assert (std::holds_alternative<std::optional< ActorIsolation> >(data) &&
150
+ assert (std::holds_alternative<ActorIsolation>(data) &&
152
151
" Doesn't have an actor isolation?!" );
153
- return std::get<std::optional<ActorIsolation>>(data);
154
- }
155
-
156
- NominalTypeDecl *getActorInstance () const {
157
- assert (kind == Actor);
158
- assert (std::holds_alternative<NominalTypeDecl *>(data) &&
159
- " Doesn't have an actor instance?!" );
160
- return std::get<NominalTypeDecl *>(data);
152
+ return std::get<ActorIsolation>(data);
161
153
}
162
154
163
155
SILValue getTaskIsolatedValue () const {
@@ -167,45 +159,31 @@ class SILIsolationInfo {
167
159
return std::get<SILValue>(data);
168
160
}
169
161
170
- bool hasActorIsolation () const {
171
- return kind == Actor &&
172
- std::holds_alternative<std::optional<ActorIsolation>>(data);
173
- }
174
-
175
- bool hasActorInstance () const {
176
- return kind == Actor && std::holds_alternative<NominalTypeDecl *>(data);
177
- }
162
+ bool hasActorIsolation () const { return kind == Actor; }
178
163
179
164
bool hasTaskIsolatedValue () const {
180
165
return kind == Task && std::holds_alternative<SILValue>(data);
181
166
}
182
167
183
- // / If we actually have an actor decl, return that. Otherwise, see if we have
184
- // / an actor isolation if we can find one in there. Returns nullptr if we
185
- // / fail.
186
- NominalTypeDecl *tryInferActorDecl () const ;
187
-
188
168
[[nodiscard]] SILIsolationInfo merge (SILIsolationInfo other) const ;
189
169
190
170
SILIsolationInfo withActorIsolated (ActorIsolation isolation) {
191
171
return SILIsolationInfo::getActorIsolated (isolation);
192
172
}
193
173
194
- static SILIsolationInfo getDisconnected () { return {Kind::Disconnected, {} }; }
174
+ static SILIsolationInfo getDisconnected () { return {Kind::Disconnected}; }
195
175
196
176
static SILIsolationInfo getActorIsolated (ActorIsolation actorIsolation) {
197
- return {Kind::Actor, actorIsolation};
177
+ return {actorIsolation};
198
178
}
199
179
200
- // / Sometimes we may have something that is actor isolated or that comes from
201
- // / a type. First try getActorIsolation and otherwise, just use the type.
202
- static SILIsolationInfo getActorIsolated (NominalTypeDecl *nomDecl) {
203
- auto actorIsolation = swift::getActorIsolation (nomDecl);
204
- if (actorIsolation.isActorIsolated ())
205
- return getActorIsolated (actorIsolation);
206
- if (nomDecl->isActor ())
207
- return {Kind::Actor, nomDecl};
208
- return SILIsolationInfo ();
180
+ static SILIsolationInfo getActorIsolated (NominalTypeDecl *typeDecl) {
181
+ if (typeDecl->isActor ())
182
+ return {ActorIsolation::forActorInstanceSelf (typeDecl)};
183
+ auto isolation = swift::getActorIsolation (typeDecl);
184
+ if (isolation.isGlobalActor ())
185
+ return {isolation};
186
+ return {};
209
187
}
210
188
211
189
static SILIsolationInfo getGlobalActorIsolated (Type globalActorType) {
0 commit comments