@@ -3156,6 +3156,12 @@ bool ConstraintSystem::repairFailures(
3156
3156
// for this call, we can consider overload unrelated.
3157
3157
if (llvm::any_of (getFixes (), [&](const ConstraintFix *fix) {
3158
3158
auto *locator = fix->getLocator ();
3159
+ // Since arguments to @dynamicCallable form either an array
3160
+ // or a dictionary and all have to match the same element type,
3161
+ // let's allow multiple invalid arguments.
3162
+ if (locator->findFirst <LocatorPathElt::DynamicCallable>())
3163
+ return false ;
3164
+
3159
3165
return locator->findLast <LocatorPathElt::ApplyArgToParam>()
3160
3166
? locator->getAnchor () == anchor
3161
3167
: false ;
@@ -7841,14 +7847,20 @@ ConstraintSystem::simplifyDynamicCallableApplicableFnConstraint(
7841
7847
addConstraint (ConstraintKind::Defaultable, argumentType,
7842
7848
ctx.TheAnyType , locator);
7843
7849
7850
+ auto *baseArgLoc = getConstraintLocator (
7851
+ loc->getAnchor (),
7852
+ {ConstraintLocator::DynamicCallable, ConstraintLocator::ApplyArgument},
7853
+ /* summaryFlags=*/ 0 );
7854
+
7844
7855
// All dynamic call parameter types must be convertible to the argument type.
7845
7856
for (auto i : indices (func1->getParams ())) {
7846
7857
auto param = func1->getParams ()[i];
7847
7858
auto paramType = param.getPlainType ();
7848
- auto locatorBuilder =
7849
- locator.withPathElement (LocatorPathElt::TupleElement (i));
7850
- addConstraint (ConstraintKind::ArgumentConversion, paramType,
7851
- argumentType, locatorBuilder);
7859
+
7860
+ addConstraint (
7861
+ ConstraintKind::ArgumentConversion, paramType, argumentType,
7862
+ getConstraintLocator (baseArgLoc, LocatorPathElt::ApplyArgToParam (
7863
+ i, 0 , param.getParameterFlags ())));
7852
7864
}
7853
7865
7854
7866
return SolutionKind::Solved;
0 commit comments