Merge pull request #84384 from ktoso/wip-distributed-red-conf

This commit is contained in:
Konrad `ktoso` Malawski
2025-09-22 21:00:26 +09:00
committed by GitHub
4 changed files with 34 additions and 15 deletions

View File

@@ -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 (auto classDecl = dyn_cast<ClassDecl>(mutableThis)) {
if (classDecl->isDistributedActor()) { if (classDecl->isDistributedActor()) {
addSynthesized(ctx.getProtocol(KnownProtocolKind::DistributedActor)); addSynthesized(ctx.getProtocol(KnownProtocolKind::DistributedActor));

View File

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

View File

@@ -73,9 +73,6 @@ public distributed actor DAG<ActorSystem> where ActorSystem: DistributedActorSys
// CHECK: } // 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-NOT: #if compiler(>=5.3) && $Actors
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) // CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
// CHECK-NEXT:extension Library.DA : Swift.Encodable {} // CHECK-NEXT:extension Library.DA : Swift.Encodable {}
@@ -83,10 +80,6 @@ public distributed actor DAG<ActorSystem> where ActorSystem: DistributedActorSys
// CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) // CHECK: @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
// CHECK-NEXT:extension Library.DA : Swift.Decodable {} // 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 //--- Client.swift
import Distributed import Distributed

View File

@@ -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 {}