Skip to content

Commit 1ea4e91

Browse files
committed
Simplify the check; conforming to (Distributed)Actor is not right in any case
1 parent d73b907 commit 1ea4e91

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,9 @@ class InheritedProtocolCollector {
689689
return;
690690

691691
/// is this nominal specifically an 'actor' or 'distributed actor'?
692-
bool actorClass = false;
693-
bool distributedActorClass = false;
692+
bool anyActorClass = false;
694693
if (auto klass = dyn_cast<ClassDecl>(nominal)) {
695-
actorClass = klass->isActor();
696-
distributedActorClass = klass->isDistributedActor();
694+
anyActorClass = klass->isAnyActor();
697695
}
698696

699697
SmallPtrSet<ProtocolDecl *, 16> handledProtocols;
@@ -729,12 +727,11 @@ class InheritedProtocolCollector {
729727
// There is a special restriction on the Actor protocol in that
730728
// it is only valid to conform to Actor on an 'actor' decl,
731729
// not extensions of that 'actor'.
732-
if (actorClass &&
733-
inherited->isSpecificProtocol(KnownProtocolKind::Actor))
734-
return TypeWalker::Action::SkipNode;
735-
if (distributedActorClass &&
736-
inherited->isSpecificProtocol(KnownProtocolKind::DistributedActor))
737-
return TypeWalker::Action::SkipNode;
730+
if (anyActorClass) {
731+
if (inherited->isSpecificProtocol(KnownProtocolKind::Actor) ||
732+
inherited->isSpecificProtocol(KnownProtocolKind::DistributedActor))
733+
return TypeWalker::Action::SkipNode;
734+
}
738735

739736
// Do not synthesize an extension to print a conformance to an
740737
// invertible protocol, as their conformances are always re-inferred

test/ModuleInterface/distributed_no_redundant_conformance.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
// RUN: %target-swift-emit-module-interface(%t/TestResilient.swiftinterface) %s -module-name TestResilient
44
// RUN: %target-swift-typecheck-module-from-interface(%t/TestResilient.swiftinterface) -module-name TestResilient
5-
// RUN: %FileCheck %s --dump-input=always < %t/TestResilient.swiftinterface
6-
7-
// RUN: %target-swift-frontend -compile-module-from-interface -swift-version 5 %t/TestResilient.swiftinterface -o %t/TestResilient.swiftmodule
8-
// RUN: %target-swift-frontend -emit-module -o /dev/null -merge-modules -swift-version 5 -emit-module-interface-path - %t/TestResilient.swiftmodule -module-name TestResilient | %FileCheck %s
5+
// RUN: %FileCheck %s < %t/TestResilient.swiftinterface
96

107
import Distributed
118

@@ -23,4 +20,4 @@ public distributed actor DistributedExample {
2320

2421
// CHECK: distributed public actor DistributedExample {
2522

26-
// CHECK-NOT: extension TestResilient.DistributedExample : Distributed.DistributedActor {}
23+
// CHECK-NOT: extension TestResilient.DistributedExample : Distributed.DistributedActor {}

0 commit comments

Comments
 (0)