Simplify the check; conforming to (Distributed)Actor is not right in any case

This commit is contained in:
Konrad Malawski
2025-09-19 09:06:04 +09:00
parent d73b907d66
commit 1ea4e914e3
2 changed files with 9 additions and 15 deletions

View File

@@ -689,11 +689,9 @@ public:
return;
/// is this nominal specifically an 'actor' or 'distributed actor'?
bool actorClass = false;
bool distributedActorClass = false;
bool anyActorClass = false;
if (auto klass = dyn_cast<ClassDecl>(nominal)) {
actorClass = klass->isActor();
distributedActorClass = klass->isDistributedActor();
anyActorClass = klass->isAnyActor();
}
SmallPtrSet<ProtocolDecl *, 16> handledProtocols;
@@ -729,12 +727,11 @@ public:
// There is a special restriction on the Actor protocol in that
// it is only valid to conform to Actor on an 'actor' decl,
// not extensions of that 'actor'.
if (actorClass &&
inherited->isSpecificProtocol(KnownProtocolKind::Actor))
return TypeWalker::Action::SkipNode;
if (distributedActorClass &&
inherited->isSpecificProtocol(KnownProtocolKind::DistributedActor))
return TypeWalker::Action::SkipNode;
if (anyActorClass) {
if (inherited->isSpecificProtocol(KnownProtocolKind::Actor) ||
inherited->isSpecificProtocol(KnownProtocolKind::DistributedActor))
return TypeWalker::Action::SkipNode;
}
// Do not synthesize an extension to print a conformance to an
// invertible protocol, as their conformances are always re-inferred