Skip to content

Commit 670f69e

Browse files
authored
Merge pull request #83491 from rjmccall/strengthen-sil-function-type-isolation-preconditions
Strengthen SILFunctionType's isolation preconditions
2 parents 2f6f3aa + 9a3ba0e commit 670f69e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
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.

lib/AST/ASTContext.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5350,8 +5350,13 @@ SILFunctionType::SILFunctionType(
53505350
"Cannot return an @noescape function type");
53515351
}
53525352
}
5353+
bool hasIsolatedParameter = false; (void) hasIsolatedParameter;
53535354
for (auto param : getParameters()) {
5354-
(void)param;
5355+
if (param.hasOption(SILParameterInfo::Isolated)) {
5356+
assert(!hasIsolatedParameter &&
5357+
"building SIL function type with multiple isolated parameters");
5358+
hasIsolatedParameter = true;
5359+
}
53555360
assert(!isa<PackExpansionType>(param.getInterfaceType()) &&
53565361
"Cannot have a pack expansion directly as a parameter");
53575362
assert(param.isPack() == isa<SILPackType>(param.getInterfaceType()) &&

0 commit comments

Comments
 (0)