1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
|
// 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-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking -plugin-path %swift-plugin-dir -parse-as-library -I %t %S/../Inputs/FakeDistributedActorSystems.swift -dump-macro-expansions %s -dump-macro-expansions 2>&1 | %FileCheck %s
import Distributed
@Resolvable
protocol Greeter: DistributedActor where ActorSystem == FakeActorSystem {
distributed func greet(name: String) -> String
}
// CHECK: distributed actor $Greeter: Greeter,
// CHECK: Distributed._DistributedActorStub
// CHECK: {
// CHECK: typealias ActorSystem = FakeActorSystem
// CHECK: }
// CHECK: extension Greeter where Self: Distributed._DistributedActorStub {
// CHECK: distributed func greet(name: String) -> String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: }
@Resolvable
protocol Greeter2: DistributedActor where ActorSystem: DistributedActorSystem<any Codable> {
distributed func greet(name: String) -> String
}
// CHECK: distributed actor $Greeter2<ActorSystem>: Greeter2,
// CHECK: Distributed._DistributedActorStub
// CHECK: where ActorSystem: DistributedActorSystem<any Codable>
// CHECK: {
// CHECK: }
// CHECK: extension Greeter2 where Self: Distributed._DistributedActorStub {
// CHECK: distributed func greet(name: String) -> String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: }
extension String: CustomSerializationProtocol {
public func toBytes() throws -> [UInt8] { [] }
public static func fromBytes(_ bytes: [UInt8]) throws -> Self { "" }
}
@Resolvable
protocol Greeter3: DistributedActor where ActorSystem: DistributedActorSystem<any CustomSerializationProtocol> {
distributed func greet(name: String) -> String
}
// CHECK: distributed actor $Greeter3<ActorSystem>: Greeter3,
// CHECK: Distributed._DistributedActorStub
// CHECK: where ActorSystem: DistributedActorSystem<any CustomSerializationProtocol>
// CHECK: {
// CHECK: }
// CHECK: extension Greeter3 where Self: Distributed._DistributedActorStub {
// CHECK: distributed func greet(name: String) -> String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: }
@Resolvable
public protocol Greeter4: DistributedActor where ActorSystem == FakeActorSystem {
distributed func greet(name: String) -> String
}
// CHECK: public distributed actor $Greeter4: Greeter4,
// CHECK: Distributed._DistributedActorStub
// CHECK: {
// CHECK: public typealias ActorSystem = FakeActorSystem
// CHECK: }
// CHECK: extension Greeter4 where Self: Distributed._DistributedActorStub {
// CHECK: public distributed func greet(name: String) -> String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: }
@Resolvable
public protocol GreeterMore: DistributedActor where ActorSystem == FakeActorSystem {
distributed var name: String { get }
distributed func greet(name: String) -> String
distributed func another(string: String, int: Int) async throws -> Double
distributed func generic<T: Codable>(value: T, int: Int) async throws -> T
}
// CHECK: public distributed actor $GreeterMore: GreeterMore,
// CHECK: Distributed._DistributedActorStub
// CHECK: {
// CHECK: public typealias ActorSystem = FakeActorSystem
// CHECK: }
// CHECK: extension GreeterMore where Self: Distributed._DistributedActorStub {
// CHECK: public distributed var name : String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: public distributed func greet(name: String) -> String {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: public distributed func another(string: String, int: Int) async throws -> Double {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: public distributed func generic<T: Codable>(value: T, int: Int) async throws -> T {
// CHECK: if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) {
// CHECK: Distributed._distributedStubFatalError()
// CHECK: } else {
// CHECK: fatalError()
// CHECK: }
// CHECK: }
// CHECK: }
// Should not fail:
public protocol MyActorWithSystemRequirement: DistributedActor where ActorSystem == FakeActorSystem {}
@Resolvable
public protocol MyActorWithSystemRequirementImpl: MyActorWithSystemRequirement {
distributed func example()
}
|