Skip to content

Commit 8223abe

Browse files
xedinktoso
authored andcommitted
[CSApply] Produce an abstract conformance for Res parameter of DistributedActorSystem.remoteCall witness
1 parent 089596a commit 8223abe

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lib/Sema/CSApply.cpp

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

107+
auto *DC = constraintSystem->DC;
107108
auto lookupConformanceFn =
108109
[&](CanType original, Type replacement,
109110
ProtocolDecl *protoType) -> ProtocolConformanceRef {
@@ -114,8 +115,24 @@ Solution::computeSubstitutions(NullablePtr<ValueDecl> decl,
114115
}
115116

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

121138
return SubstitutionMap::get(sig,

0 commit comments

Comments
 (0)