Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/AST/ProtocolConformance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ void NominalTypeDecl::prepareConformanceTable() const {
}
}

// Actor classes conform to the actor protocol.
// Actor classes conform to the appropriate actor protocol.
if (auto classDecl = dyn_cast<ClassDecl>(mutableThis)) {
if (classDecl->isDistributedActor()) {
addSynthesized(ctx.getProtocol(KnownProtocolKind::DistributedActor));
Expand Down
17 changes: 10 additions & 7 deletions lib/Frontend/ModuleInterfaceSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,11 @@ class InheritedProtocolCollector {
if (!printOptions.shouldPrint(nominal))
return;

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

SmallPtrSet<ProtocolDecl *, 16> handledProtocols;

Expand Down Expand Up @@ -726,9 +727,11 @@ class InheritedProtocolCollector {
// 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 (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
Expand Down
7 changes: 0 additions & 7 deletions test/ModuleInterface/distributed-actor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,13 @@ public distributed actor DAG<ActorSystem> where ActorSystem: DistributedActorSys
// CHECK: }
}

// CHECK-NOT: #if compiler(>=5.3) && $Actors
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
// CHECK-NEXT:extension Library.DA : Distributed.DistributedActor {}
// CHECK-NOT: #if compiler(>=5.3) && $Actors
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
// CHECK-NEXT:extension Library.DA : Swift.Encodable {}
// CHECK-NOT: #if compiler(>=5.3) && $Actors
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
// CHECK-NEXT:extension Library.DA : Swift.Decodable {}

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

//--- Client.swift

import Distributed
Expand Down
23 changes: 23 additions & 0 deletions test/ModuleInterface/distributed_no_redundant_conformance.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-emit-module-interface(%t/TestResilient.swiftinterface) %s -module-name TestResilient
// RUN: %target-swift-typecheck-module-from-interface(%t/TestResilient.swiftinterface) -module-name TestResilient
// RUN: %FileCheck %s < %t/TestResilient.swiftinterface

import Distributed

// Note that tat while an actor is implicitly conforming to Actor, we don't need to print this in interfaces
// as it would cause 'redundant conformance of ... to (Distributed)Actor' issues.

public actor Example {}

// CHECK-NOT: extension TestResilient.Example : _Concurrency.Actor {}

public distributed actor DistributedExample {
public typealias ActorSystem = LocalTestingDistributedActorSystem
distributed func example() {}
}

// CHECK: distributed public actor DistributedExample {

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