Skip to content

Commit 6f9aef4

Browse files
committed
Add an equality operator on FunctionTypeIsolation
1 parent d8cfe92 commit 6f9aef4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

include/swift/AST/ExtInfo.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,26 @@ class FunctionTypeIsolation {
127127
return getKind() == Kind::NonIsolatedCaller;
128128
}
129129

130+
/// Two function type isolations are equal if they have the same kind and
131+
/// (when applicable) the same global actor types.
132+
///
133+
/// Exact equality is the right thing to ask about when deciding whether
134+
/// two isolations are the same statically, because we have to treat
135+
/// different specializations of the same generic global actor type
136+
/// as potentially different isolations. (Of course, you must be comparing
137+
/// types that have been mapped into the same context.)
138+
///
139+
/// Exact equality is *not* the right thing to ask about when deciding
140+
/// whether two isolations might be the same dynamically, because two
141+
/// different specializations of the same generic global actor type
142+
/// could absolutely end up being the same in concrete specialization.
143+
bool operator==(FunctionTypeIsolation other) const {
144+
return value == other.value;
145+
}
146+
bool operator!=(FunctionTypeIsolation other) const {
147+
return value != other.value;
148+
}
149+
130150
// The opaque accessors below are just for the benefit of ExtInfoBuilder,
131151
// which finds it convenient to break down the type separately. Normal
132152
// clients should use the accessors above.

0 commit comments

Comments
 (0)