[Distributed] distributed func checks now work in protocols & dont crash

This commit is contained in:
Konrad `ktoso` Malawski
2022-06-24 17:45:55 +09:00
parent 22b20afce6
commit fa077c1390
7 changed files with 47 additions and 5 deletions

View File

@@ -29,6 +29,41 @@ distributed actor SpecifyRequirement: NoSerializationRequirementYet {
distributed func testAT() async throws -> NotCodable {
.init()
}
}
protocol ProtocolWithChecksSystem: DistributedActor
where ActorSystem == FakeActorSystem {
// expected-error@+1{{result type 'NotCodable' of distributed instance method 'testAT' does not conform to serialization requirement 'Codable'}}
distributed func testAT() async throws -> NotCodable
}
distributed actor ProtocolWithChecksSystemDA: ProtocolWithChecksSystem {
// expected-error@+1{{result type 'NotCodable' of distributed instance method 'testAT' does not conform to serialization requirement 'Codable'}}
distributed func testAT() async throws -> NotCodable { .init() }
}
protocol ProtocolWithChecksSeqReq: DistributedActor
where Self.SerializationRequirement == Codable {
// expected-error@+1{{result type 'NotCodable' of distributed instance method 'testAT' does not conform to serialization requirement 'Codable'}}
distributed func testAT() async throws -> NotCodable
}
distributed actor ProtocolWithChecksSeqReqDA_MissingSystem: ProtocolWithChecksSeqReq {
// expected-error@-1{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with.}}
// expected-note@-2{{you can provide a module-wide default actor system by declaring:}}
// expected-error@-3{{type 'ProtocolWithChecksSeqReqDA_MissingSystem' does not conform to protocol 'ProtocolWithChecksSeqReq'}}
//
// expected-error@-5{{distributed actor 'ProtocolWithChecksSeqReqDA_MissingSystem' does not declare ActorSystem it can be used with.}}
// Entire conformance is doomed, so we didn't proceed to checking the functions; that's fine
distributed func testAT() async throws -> NotCodable { .init() }
}
distributed actor ProtocolWithChecksSeqReqDA: ProtocolWithChecksSeqReq {
typealias ActorSystem = FakeActorSystem
// ok, since FakeActorSystem.SerializationRequirement == ProtocolWithChecksSeqReq.SerializationRequirement
// expected-error@+1{{result type 'NotCodable' of distributed instance method 'testAT' does not conform to serialization requirement 'Codable'}}
distributed func testAT() async throws -> NotCodable { .init() }
}
extension NoSerializationRequirementYet {