@@ -938,7 +938,8 @@ class ArgumentFailureTracker : public MatchCallArgumentListener {
938
938
// Match the argument of a call to the parameter.
939
939
ConstraintSystem::TypeMatchResult constraints::matchCallArguments (
940
940
ConstraintSystem &cs, ArrayRef<AnyFunctionType::Param> args,
941
- ArrayRef<AnyFunctionType::Param> params, ConstraintLocatorBuilder locator) {
941
+ ArrayRef<AnyFunctionType::Param> params, ConstraintKind subKind,
942
+ ConstraintLocatorBuilder locator) {
942
943
// Extract the parameters.
943
944
ValueDecl *callee;
944
945
bool hasCurriedSelf;
@@ -971,12 +972,6 @@ ConstraintSystem::TypeMatchResult constraints::matchCallArguments(
971
972
// assignment operators.
972
973
auto *anchor = locator.getAnchor ();
973
974
assert (anchor && " locator without anchor expression?" );
974
- bool isOperator = (isa<PrefixUnaryExpr>(anchor) ||
975
- isa<PostfixUnaryExpr>(anchor) || isa<BinaryExpr>(anchor));
976
-
977
- ConstraintKind subKind = (isOperator
978
- ? ConstraintKind::OperatorArgumentConversion
979
- : ConstraintKind::ArgumentConversion);
980
975
981
976
// Check whether argument of the call at given position refers to
982
977
// parameter marked as `@autoclosure`. This function is used to
@@ -5605,6 +5600,12 @@ ConstraintSystem::simplifyApplicableFnConstraint(
5605
5600
5606
5601
TypeMatchOptions subflags = getDefaultDecompositionOptions (flags);
5607
5602
5603
+ SmallVector<LocatorPathElt, 2 > parts;
5604
+ Expr *anchor = locator.getLocatorParts (parts);
5605
+ bool isOperator = (isa<PrefixUnaryExpr>(anchor) ||
5606
+ isa<PostfixUnaryExpr>(anchor) ||
5607
+ isa<BinaryExpr>(anchor));
5608
+
5608
5609
// If the types are obviously equivalent, we're done.
5609
5610
if (type1.getPointer () == desugar2)
5610
5611
return SolutionKind::Solved;
@@ -5640,8 +5641,6 @@ ConstraintSystem::simplifyApplicableFnConstraint(
5640
5641
5641
5642
// Strip the 'ApplyFunction' off the locator.
5642
5643
// FIXME: Perhaps ApplyFunction can go away entirely?
5643
- SmallVector<LocatorPathElt, 2 > parts;
5644
- Expr *anchor = locator.getLocatorParts (parts);
5645
5644
assert (!parts.empty () && " Nonsensical applicable-function locator" );
5646
5645
assert (parts.back ().getKind () == ConstraintLocator::ApplyFunction);
5647
5646
assert (parts.back ().getNewSummaryFlags () == 0 );
@@ -5670,9 +5669,13 @@ ConstraintSystem::simplifyApplicableFnConstraint(
5670
5669
5671
5670
// For a function, bind the output and convert the argument to the input.
5672
5671
if (auto func2 = dyn_cast<FunctionType>(desugar2)) {
5672
+ ConstraintKind subKind = (isOperator
5673
+ ? ConstraintKind::OperatorArgumentConversion
5674
+ : ConstraintKind::ArgumentConversion);
5675
+
5673
5676
// The argument type must be convertible to the input type.
5674
5677
if (::matchCallArguments (
5675
- *this , func1->getParams (), func2->getParams (),
5678
+ *this , func1->getParams (), func2->getParams (), subKind,
5676
5679
outerLocator.withPathElement (ConstraintLocator::ApplyArgument))
5677
5680
.isFailure ())
5678
5681
return SolutionKind::Error;
0 commit comments