Skip to content

Commit 6afa732

Browse files
committed
[CSApply] Produce an abstract conformance for Res parameter of DistributedActorSystem.remoteCall witness
1 parent f7e01fb commit 6afa732

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/Sema/CSApply.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
105105
subs[opened.first] = type;
106106
}
107107

108+
auto *DC = constraintSystem->DC;
108109
auto lookupConformanceFn =
109110
[&](CanType original, Type replacement,
110111
ProtocolDecl *protoType) -> ProtocolConformanceRef {
@@ -115,8 +116,25 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
115116
}
116117

117118
// FIXME: Retrieve the conformance from the solution itself.
118-
return getConstraintSystem().DC->getParentModule()->lookupConformance(
119-
replacement, protoType, /*allowMissing=*/true);
119+
auto conformance =
120+
getConstraintSystem().DC->getParentModule()->lookupConformance(
121+
replacement, protoType, /*allowMissing=*/true);
122+
123+
if (conformance.isInvalid()) {
124+
if (auto *funcDecl = dyn_cast<FuncDecl>(decl.getPtrOrNull())) {
125+
if (funcDecl->isDistributedActorSystemRemoteCall(
126+
/*isVoidResult=*/false)) {
127+
// `Res` conformances would be looked by at runtime but are
128+
// guaranteed to be there by Sema because all distributed
129+
// methods and accessors are checked to conform to
130+
// `SerializationRequirement` of `DistributedActorSystem`.
131+
if (original->isEqual(funcDecl->getResultInterfaceType()))
132+
return ProtocolConformanceRef(protoType);
133+
}
134+
}
135+
}
136+
137+
return conformance;
120138
};
121139

122140
return SubstitutionMap::get(sig,

0 commit comments

Comments
 (0)