mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The proposal was [accepted with modifications](https://forums.swift.org/t/accepted-with-modifications-se-0428-resolve-distributedactor-protocols/71366) The decision was made to change the spelling of the attached macro in the proposal from @DistributedProtocol to `@Resolvable` (or `@Distributed.Resolvable` if disambiguation is needed).
48 lines
1.4 KiB
Swift
48 lines
1.4 KiB
Swift
// REQUIRES: swift_swift_parser, asserts
|
|
//
|
|
// UNSUPPORTED: back_deploy_concurrency
|
|
// REQUIRES: concurrency
|
|
// REQUIRES: distributed
|
|
//
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %empty-directory(%t-scratch)
|
|
|
|
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -plugin-path %swift-plugin-dir -I %t -dump-macro-expansions %s -dump-macro-expansions 2>&1 | %FileCheck %s
|
|
|
|
import Distributed
|
|
|
|
@Resolvable
|
|
protocol Greeter: DistributedActor where ActorSystem: DistributedActorSystem<any Codable> {
|
|
distributed func greet(name: String) -> String
|
|
}
|
|
|
|
// @Resolvable ->
|
|
|
|
// CHECK: distributed actor $Greeter<ActorSystem>: Greeter,
|
|
// CHECK-NEXT: Distributed._DistributedActorStub
|
|
// CHECK-NEXT: where ActorSystem: DistributedActorSystem<any Codable>
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: extension Greeter where Self: Distributed._DistributedActorStub {
|
|
// CHECK-NEXT: distributed func greet(name: String) -> String {
|
|
// CHECK-NEXT: if #available(SwiftStdlib 6.0, *) {
|
|
// CHECK-NEXT: Distributed._distributedStubFatalError()
|
|
// CHECK-NEXT: } else {
|
|
// CHECK-NEXT: fatalError()
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: }
|
|
|
|
// Macro should be able to handle complex properties
|
|
@Resolvable
|
|
public protocol GetSet: DistributedActor, Sendable
|
|
where ActorSystem: DistributedActorSystem<any Codable> {
|
|
|
|
distributed var dist: String { get }
|
|
|
|
var getSet: String { get set }
|
|
|
|
var asyncGetSet: String { get async throws }
|
|
}
|