Skip to content

[Distributed] Handle composite type in generic bound in distributed accessor #67117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/IRGen/GenDistributed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ void DistributedAccessor::emit() {

auto params = IGF.collectParameters();

GenericContextScope scope(IGM, targetTy->getInvocationGenericSignature());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix™ is that this must be made before the IGM getTypeInfo call, otherwise the generic context is not available (null) and we crash.


auto directResultTy = targetConv.getSILResultType(expansionContext);
const auto &directResultTI = IGM.getTypeInfo(directResultTy);

Expand Down Expand Up @@ -652,8 +654,6 @@ void DistributedAccessor::emit() {
// Witness table for decoder conformance to DistributedTargetInvocationDecoder
auto *decoderProtocolWitness = params.claimNext();

GenericContextScope scope(IGM, targetTy->getInvocationGenericSignature());

// Preliminary: Setup async context for this accessor.
{
auto fpKind = FunctionPointerKind::defaultAsync();
Expand Down
22 changes: 22 additions & 0 deletions test/IRGen/distributed_actor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,25 @@ public distributed actor MyActor {
public typealias ActorSystem = LocalTestingDistributedActorSystem
// nothing
}

/// This combination of DistributedActor + Codable used to trigger a crash in DistributedAccessor::emit (rdar://111664985)
/// So returning it from distributed methods in the types below covers this radar.
public protocol ClusterSingleton: DistributedActor, Codable {}

@available(SwiftStdlib 5.6, *)
public distributed actor MyActorGenerics {
public typealias ActorSystem = LocalTestingDistributedActorSystem

distributed func find<Act: ClusterSingleton>(byName name: String) -> Act {
fatalError("mock impl")
}
}

@available(SwiftStdlib 5.6, *)
public distributed actor MyActorGenericsOnType<Act: ClusterSingleton> {
public typealias ActorSystem = LocalTestingDistributedActorSystem

distributed func find(byName name: String) -> Act {
fatalError("mock impl")
}
}