Skip to content

Commit 96c5d83

Browse files
authored
[Distributed] Map into context computed property result type for SerReq checking (swiftlang#75467)
1 parent 64bcabc commit 96c5d83

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,10 @@ static bool checkDistributedTargetResultType(
420420
if (auto func = dyn_cast<FuncDecl>(valueDecl)) {
421421
resultType = func->mapTypeIntoContext(func->getResultInterfaceType());
422422
} else if (auto var = dyn_cast<VarDecl>(valueDecl)) {
423-
resultType = var->getInterfaceType();
423+
// Distributed computed properties are always getters,
424+
// so get the get accessor for mapping the type into context:
425+
auto getter = var->getAccessor(swift::AccessorKind::Get);
426+
resultType = getter->mapTypeIntoContext(var->getInterfaceType());
424427
} else {
425428
llvm_unreachable("Unsupported distributed target");
426429
}

test/Distributed/distributed_protocols_distributed_func_serialization_requirements.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ extension ProtocolWithChecksSeqReqDA {
9696
}
9797
}
9898

99+
protocol Recipient: DistributedActor where ActorSystem == FakeActorSystem {
100+
associatedtype Info: Sendable & Codable // is Codable, should be ok
101+
distributed var info: Info { get async }
102+
distributed func getInfo() -> Info
103+
}
104+
105+
distributed actor RecipientImpl: Recipient {
106+
typealias Info = String
107+
distributed var info: Info { "info" }
108+
distributed func getInfo() -> Info { "info" }
109+
}
110+
99111
// FIXME(distributed): remove the -verify-ignore-unknown
100112
// <unknown>:0: error: unexpected error produced: instance method 'recordReturnType' requires that 'NotCodable' conform to 'Decodable'
101113
// <unknown>:0: error: unexpected error produced: instance method 'recordReturnType' requires that 'NotCodable' conform to 'Encodable'

0 commit comments

Comments
 (0)