@@ -223,17 +223,8 @@ class IsolationRegionInfo {
223
223
224
224
// TODO: Make this failing mean that we emit an unknown SIL error instead of
225
225
// asserting.
226
- if (other.isActorIsolated () && isActorIsolated ()) {
227
- if (other.hasActorInstance () && hasActorInstance ()) {
228
- assert (other.getActorInstance () == getActorInstance () &&
229
- " Actor should never be merged with another actor unless with "
230
- " the same actor?!" );
231
- } else if (other.hasActorIsolation () && hasActorIsolation ()) {
232
- assert (other.getActorIsolation () == getActorIsolation () &&
233
- " Actor should never be merged with another actor unless with "
234
- " the same actor?!" );
235
- }
236
- }
226
+ assert ((!other.isActorIsolated () || !isActorIsolated () || *this == other) &&
227
+ " Actor can only be merged with the same actor" );
237
228
238
229
// Otherwise, take the other value.
239
230
return other;
@@ -265,6 +256,36 @@ class IsolationRegionInfo {
265
256
static IsolationRegionInfo getTaskIsolated (SILValue value) {
266
257
return {Kind::Task, value};
267
258
}
259
+
260
+ bool operator ==(const IsolationRegionInfo &other) const {
261
+ if (getKind () != other.getKind ())
262
+ return false ;
263
+
264
+ switch (getKind ()) {
265
+ case Unknown:
266
+ case Disconnected:
267
+ return true ;
268
+ case Task:
269
+ return getTaskIsolatedValue () == other.getTaskIsolatedValue ();
270
+ case Actor:
271
+ // First try to use actor isolation if we have them.
272
+ if (hasActorIsolation () && other.hasActorIsolation ()) {
273
+ auto lhsIsolation = getActorIsolation ();
274
+ auto rhsIsolation = other.getActorIsolation ();
275
+ if (lhsIsolation && rhsIsolation)
276
+ return *lhsIsolation == *rhsIsolation;
277
+ }
278
+
279
+ // Otherwise, try to use the inferred actor decl.
280
+ auto *lhsDecl = tryInferActorDecl ();
281
+ auto *rhsDecl = tryInferActorDecl ();
282
+ if (lhsDecl && rhsDecl)
283
+ return lhsDecl == rhsDecl;
284
+
285
+ // Otherwise, false, they are not equal.
286
+ return false ;
287
+ }
288
+ }
268
289
};
269
290
270
291
} // namespace swift
0 commit comments