mirror of
https://github.com/apple/swift.git
synced 2026-10-04 11:58:22 +02:00
70 lines
2.5 KiB
Swift
70 lines
2.5 KiB
Swift
// RUN: %target-swift-frontend -typecheck -verify -verify-ignore-unrelated -enable-experimental-feature Embedded -enable-experimental-feature EmbeddedDistributed -parse-as-library -wmo -target %target-cpu-apple-macos14 %s
|
|
|
|
// REQUIRES: OS=macosx
|
|
// REQUIRES: swift_feature_Embedded
|
|
// REQUIRES: swift_feature_EmbeddedDistributed
|
|
// REQUIRES: optimized_stdlib
|
|
|
|
// Missing remoteCall implementation should diagnose the right "Embedded shape" that users must implement.
|
|
|
|
import _Concurrency
|
|
import Distributed
|
|
|
|
public struct EmbeddedActorID: Sendable, Hashable {
|
|
public let id: UInt64
|
|
}
|
|
|
|
public protocol MySerializationRequirement {}
|
|
|
|
public struct MyEncoder: DistributedTargetInvocationEncoder {
|
|
public init() {}
|
|
public mutating func doneRecording() throws {}
|
|
}
|
|
extension MyEncoder {
|
|
public mutating func recordArgument<Value: MySerializationRequirement>(
|
|
_ argument: RemoteCallArgument<Value>) throws {}
|
|
}
|
|
|
|
public struct MyDecoder: DistributedTargetInvocationDecoder {
|
|
public init() {}
|
|
}
|
|
extension MyDecoder {
|
|
public mutating func decodeNextArgument<Argument: MySerializationRequirement>() throws -> Argument {
|
|
fatalError("stub")
|
|
}
|
|
}
|
|
|
|
public struct MyResultHandler: DistributedTargetInvocationResultHandler {
|
|
public init() {}
|
|
public func onReturnVoid() async throws {}
|
|
public func onThrow(error: any Error) async throws {}
|
|
}
|
|
extension MyResultHandler {
|
|
public func onReturn<Success: MySerializationRequirement>(value: Success) async throws {}
|
|
}
|
|
|
|
public final class MySystem: DistributedActorSystem, @unchecked Sendable { // expected-error{{type 'MySystem' does not conform to protocol 'DistributedActorSystem'}}
|
|
// expected-note@-1{{add stubs for conformance}}
|
|
public typealias ActorID = EmbeddedActorID
|
|
public typealias SerializationRequirement = MySerializationRequirement
|
|
public typealias InvocationEncoder = MyEncoder
|
|
public typealias InvocationDecoder = MyDecoder
|
|
public typealias ResultHandler = MyResultHandler
|
|
|
|
public init() {}
|
|
|
|
public func resolve<Act>(id: ActorID, as actorType: Act.Type) throws -> Act?
|
|
where Act: DistributedActor, Act.ID == ActorID { return nil }
|
|
public func assignID<Act>(_ actorType: Act.Type) -> ActorID
|
|
where Act: DistributedActor, Act.ID == ActorID { return ActorID(id: 0) }
|
|
public func actorReady<Act>(_ actor: Act)
|
|
where Act: DistributedActor, Act.ID == ActorID {}
|
|
public func resignID(_ id: ActorID) {}
|
|
|
|
public func makeInvocationEncoder() -> InvocationEncoder { .init() }
|
|
|
|
// Missing impl on purpose: public func remoteCall...
|
|
// Missing impl on purpose: public func remoteCallVoid...
|
|
}
|
|
|