Giter Site home page Giter Site logo

Comments (2)

ktoso avatar ktoso commented on June 2, 2024

Thanks for the report, I'll check what's up with that.

rdar://128368486

from swift.

martialln avatar martialln commented on June 2, 2024

Foud a small reproducer:

import Distributed

public struct CustomResultHandler: DistributedTargetInvocationResultHandler {
    public typealias SerializationRequirement = any Codable
    public func onReturn<Success: Codable>(value: Success) async throws {}
    public func onReturnVoid() async throws {}
    public func onThrow<Err>(error: Err) async throws where Err : Error {}
}

public struct CustomActorInvocationEncoder: DistributedTargetInvocationEncoder {
    public typealias SerializationRequirement = any Codable
    public mutating func recordArgument<Value: Codable>(_ argument: RemoteCallArgument<Value>) throws {}
    public mutating func recordGenericSubstitution<T>(_ type: T.Type) throws {}
    public mutating func recordReturnType<R: Codable>(_ type: R.Type) throws {}
    public mutating func recordErrorType<E: Error>(_ type: E.Type) throws {}
    public mutating func doneRecording() throws {}
}

public struct CustomActorInvocationDecoder: DistributedTargetInvocationDecoder {
    public typealias SerializationRequirement = any Codable
    
    public mutating func decodeNextArgument<Argument: Codable>() throws -> Argument { fatalError() }

    public mutating func decodeGenericSubstitutions() throws -> [Any.Type] { [] }

    public mutating func decodeErrorType() throws -> (Any.Type)? { nil }
    public mutating func decodeReturnType() throws -> (Any.Type)? { nil }
}

public final class CustomActorSystem {
}


extension CustomActorSystem: DistributedActorSystem {
    public typealias SerializationRequirement = any Codable
    public typealias ActorID = Int
    public typealias InvocationEncoder = CustomActorInvocationEncoder
    public typealias InvocationDecoder = CustomActorInvocationDecoder
    public typealias ResultHandler = CustomResultHandler
    
    public func resolve<Act: DistributedActor>(id: ActorID, as actorType: Act.Type) throws -> Act? where ActorID == Act.ID {
        fatalError()
    }
    
    public func assignID<Act: DistributedActor>(_ actorType: Act.Type) -> ActorID where ActorID == Act.ID {
        fatalError()
    }
    
    public func actorReady<Act: DistributedActor>(_ actor: Act) where ActorID == Act.ID {
        fatalError()
    }
    
    public func resignID(_ id: ActorID) {
        fatalError()
    }

    public func makeInvocationEncoder() -> InvocationEncoder {
        fatalError()
    }
    
    public func remoteCall<Act: DistributedActor, Err: Error, Res: Codable>(
        on actor: Act,
        target: RemoteCallTarget,
        invocation: inout InvocationEncoder,
        throwing _: Err.Type,
        returning _: Res.Type
    ) async throws -> Res where Act.ID == ActorID {
        fatalError()
    }
    
    public func remoteCallVoid<Act: DistributedActor, Err: Error>(
        on actor: Act,
        target: RemoteCallTarget,
        invocation: inout InvocationEncoder,
        throwing error: Err.Type
    ) async throws where Act.ID == ActorID {
        fatalError()
    }
}

If you move the protocol conformance of DistributedActorSystem from the extension to the class declaration it doesn't crash anymore.

Hope that helps 😄

from swift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.