Skip to content

Commit 6f4c26f

Browse files
authored
Merge pull request #84384 from ktoso/wip-distributed-red-conf
2 parents 1a8d6a8 + 7affd14 commit 6f4c26f

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ void NominalTypeDecl::prepareConformanceTable() const {
12671267
}
12681268
}
12691269

1270-
// Actor classes conform to the actor protocol.
1270+
// Actor classes conform to the appropriate actor protocol.
12711271
if (auto classDecl = dyn_cast<ClassDecl>(mutableThis)) {
12721272
if (classDecl->isDistributedActor()) {
12731273
addSynthesized(ctx.getProtocol(KnownProtocolKind::DistributedActor));

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,11 @@ class InheritedProtocolCollector {
694694
if (!printOptions.shouldPrint(nominal))
695695
return;
696696

697-
/// is this nominal specifically an 'actor'?
698-
bool actorClass = false;
699-
if (auto klass = dyn_cast<ClassDecl>(nominal))
700-
actorClass = klass->isActor();
697+
/// is this nominal specifically an 'actor' or 'distributed actor'?
698+
bool anyActorClass = false;
699+
if (auto klass = dyn_cast<ClassDecl>(nominal)) {
700+
anyActorClass = klass->isAnyActor();
701+
}
701702

702703
SmallPtrSet<ProtocolDecl *, 16> handledProtocols;
703704

@@ -732,9 +733,11 @@ class InheritedProtocolCollector {
732733
// There is a special restriction on the Actor protocol in that
733734
// it is only valid to conform to Actor on an 'actor' decl,
734735
// not extensions of that 'actor'.
735-
if (actorClass &&
736-
inherited->isSpecificProtocol(KnownProtocolKind::Actor))
737-
return TypeWalker::Action::SkipNode;
736+
if (anyActorClass) {
737+
if (inherited->isSpecificProtocol(KnownProtocolKind::Actor) ||
738+
inherited->isSpecificProtocol(KnownProtocolKind::DistributedActor))
739+
return TypeWalker::Action::SkipNode;
740+
}
738741

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

test/ModuleInterface/distributed-actor.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,13 @@ public distributed actor DAG<ActorSystem> where ActorSystem: DistributedActorSys
7373
// CHECK: }
7474
}
7575

76-
// CHECK-NOT: #if compiler(>=5.3) && $Actors
77-
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
78-
// CHECK-NEXT:extension Library.DA : Distributed.DistributedActor {}
7976
// CHECK-NOT: #if compiler(>=5.3) && $Actors
8077
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
8178
// CHECK-NEXT:extension Library.DA : Swift.Encodable {}
8279
// CHECK-NOT: #if compiler(>=5.3) && $Actors
8380
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
8481
// CHECK-NEXT:extension Library.DA : Swift.Decodable {}
8582

86-
// CHECK-NOT: #if compiler(>=5.3) && $Actors
87-
// CHECK: @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
88-
// CHECK-NEXT: extension Library.DAG : Distributed.DistributedActor {}
89-
9083
//--- Client.swift
9184

9285
import Distributed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-emit-module-interface(%t/TestResilient.swiftinterface) %s -module-name TestResilient
4+
// RUN: %target-swift-typecheck-module-from-interface(%t/TestResilient.swiftinterface) -module-name TestResilient
5+
// RUN: %FileCheck %s < %t/TestResilient.swiftinterface
6+
7+
import Distributed
8+
9+
// Note that tat while an actor is implicitly conforming to Actor, we don't need to print this in interfaces
10+
// as it would cause 'redundant conformance of ... to (Distributed)Actor' issues.
11+
12+
public actor Example {}
13+
14+
// CHECK-NOT: extension TestResilient.Example : _Concurrency.Actor {}
15+
16+
public distributed actor DistributedExample {
17+
public typealias ActorSystem = LocalTestingDistributedActorSystem
18+
distributed func example() {}
19+
}
20+
21+
// CHECK: distributed public actor DistributedExample {
22+
23+
// CHECK-NOT: extension TestResilient.DistributedExample : Distributed.DistributedActor {}

0 commit comments

Comments
 (0)