Skip to content

Commit 1ba9716

Browse files
authored
Merge pull request #37798 from slavapestov/simplify-isactorrequest
Sema: Simplify IsActorRequest::evaluate() to avoid creating a GSB
2 parents 73bbd1d + 4cd159d commit 1ba9716

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,12 @@ void swift::addAsyncNotes(AbstractFunctionDecl const* func) {
8787

8888
bool IsActorRequest::evaluate(
8989
Evaluator &evaluator, NominalTypeDecl *nominal) const {
90-
// Protocols are actors if their `Self` type conforms to `Actor`.
90+
// Protocols are actors if they inherit from `Actor`.
9191
if (auto protocol = dyn_cast<ProtocolDecl>(nominal)) {
92-
// Simple case: we have the Actor protocol itself.
93-
if (protocol->isSpecificProtocol(KnownProtocolKind::Actor))
94-
return true;
95-
96-
auto actorProto = nominal->getASTContext().getProtocol(
97-
KnownProtocolKind::Actor);
98-
if (!actorProto)
99-
return false;
100-
101-
auto selfType = Type(protocol->getProtocolSelfType());
102-
auto genericSig = protocol->getGenericSignature();
103-
if (!genericSig)
104-
return false;
105-
106-
return genericSig->requiresProtocol(selfType, actorProto);
92+
auto &ctx = protocol->getASTContext();
93+
auto *actorProtocol = ctx.getProtocol(KnownProtocolKind::Actor);
94+
return (protocol == actorProtocol ||
95+
protocol->inheritsFrom(actorProtocol));
10796
}
10897

10998
// Class declarations are actors if they were declared with "actor".

0 commit comments

Comments
 (0)