@@ -110,20 +110,19 @@ class SILIsolationInfo {
110110 // clang-format off
111111 std::variant<
112112 // 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,
116114 // The task isolated parameter when we find a task isolated value.
117115 SILValue
118116 > data;
119117 // clang-format on
120118
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) {}
124121
125122 SILIsolationInfo (Kind kind, SILValue value) : kind(kind), data(value) {}
126123
124+ SILIsolationInfo (Kind kind) : kind(kind), data() {}
125+
127126public:
128127 SILIsolationInfo () : kind(Kind::Unknown), data() {}
129128
@@ -146,18 +145,11 @@ class SILIsolationInfo {
146145
147146 void printForDiagnostics (llvm::raw_ostream &os) const ;
148147
149- std::optional< ActorIsolation> getActorIsolation () const {
148+ ActorIsolation getActorIsolation () const {
150149 assert (kind == Actor);
151- assert (std::holds_alternative<std::optional< ActorIsolation> >(data) &&
150+ assert (std::holds_alternative<ActorIsolation>(data) &&
152151 " 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);
161153 }
162154
163155 SILValue getTaskIsolatedValue () const {
@@ -167,45 +159,31 @@ class SILIsolationInfo {
167159 return std::get<SILValue>(data);
168160 }
169161
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; }
178163
179164 bool hasTaskIsolatedValue () const {
180165 return kind == Task && std::holds_alternative<SILValue>(data);
181166 }
182167
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-
188168 [[nodiscard]] SILIsolationInfo merge (SILIsolationInfo other) const ;
189169
190170 SILIsolationInfo withActorIsolated (ActorIsolation isolation) {
191171 return SILIsolationInfo::getActorIsolated (isolation);
192172 }
193173
194- static SILIsolationInfo getDisconnected () { return {Kind::Disconnected, {} }; }
174+ static SILIsolationInfo getDisconnected () { return {Kind::Disconnected}; }
195175
196176 static SILIsolationInfo getActorIsolated (ActorIsolation actorIsolation) {
197- return {Kind::Actor, actorIsolation};
177+ return {actorIsolation};
198178 }
199179
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 {};
209187 }
210188
211189 static SILIsolationInfo getGlobalActorIsolated (Type globalActorType) {
0 commit comments