@@ -1195,13 +1195,52 @@ swift::matchWitness(WitnessChecker::RequirementEnvironmentCache &reqEnvCache,
1195
1195
}
1196
1196
bool requiresNonSendable = false ;
1197
1197
if (!solution || solution->Fixes .size ()) {
1198
- // / If the *only* problems are that `@Sendable` attributes are missing,
1199
- // / allow the match in some circumstances.
1200
- requiresNonSendable = solution
1201
- && llvm::all_of (solution->Fixes , [](constraints::ConstraintFix *fix) {
1202
- return fix->getKind () == constraints::FixKind::AddSendableAttribute;
1203
- });
1204
- if (!requiresNonSendable)
1198
+ auto isMatchedAllowed = [&](const constraints::Solution &solution) {
1199
+ // / If the *only* problems are that `@Sendable` attributes are missing,
1200
+ // / allow the match in some circumstances.
1201
+ if (llvm::all_of (solution.Fixes , [](constraints::ConstraintFix *fix) {
1202
+ return fix->getKind () ==
1203
+ constraints::FixKind::AddSendableAttribute;
1204
+ }))
1205
+ return true ;
1206
+
1207
+ auto *funcDecl = dyn_cast<AbstractFunctionDecl>(req);
1208
+ // Conformance requirement between on `Res` and `SerializationRequirement`
1209
+ // of `DistributedActorSystem.remoteCall` are not expressible at the moment
1210
+ // but they are verified by Sema so it's okay to omit them here and lookup
1211
+ // dynamically during IRGen.
1212
+ if (funcDecl && funcDecl->isDistributedActorSystemRemoteCallRequirement (
1213
+ /* withResult=*/ true )) {
1214
+ if (llvm::all_of (solution.Fixes , [&witness](constraints::ConstraintFix
1215
+ *fix) {
1216
+ auto conformance = dyn_cast<MissingConformance>(fix);
1217
+ if (!conformance)
1218
+ return false ;
1219
+
1220
+ auto *locator = fix->getLocator ();
1221
+ auto requirement = locator->getLastElementAs <
1222
+ LocatorPathElt::TypeParameterRequirement>();
1223
+ if (!requirement)
1224
+ return false ;
1225
+
1226
+ auto signature =
1227
+ locator->findLast <LocatorPathElt::OpenedGeneric>()
1228
+ ->getSignature ();
1229
+
1230
+ auto subject =
1231
+ signature.getRequirements ()[requirement->getIndex ()]
1232
+ .getFirstType ();
1233
+ // `Res` is the result type so we can check against that.
1234
+ return subject->isEqual (
1235
+ cast<FuncDecl>(witness)->getResultInterfaceType ());
1236
+ }))
1237
+ return true ;
1238
+ }
1239
+ // In all other cases - disallow the match.
1240
+ return false ;
1241
+ };
1242
+
1243
+ if (!solution || !isMatchedAllowed (*solution))
1205
1244
return RequirementMatch (witness, MatchKind::TypeConflict,
1206
1245
witnessType);
1207
1246
}
0 commit comments