@@ -756,11 +756,9 @@ class ArgumentFailureTracker : public MatchCallArgumentListener {
756
756
};
757
757
758
758
// Match the argument of a call to the parameter.
759
- ConstraintSystem::TypeMatchResult
760
- constraints::matchCallArguments (ConstraintSystem &cs, bool isOperator,
761
- ArrayRef<AnyFunctionType::Param> args,
762
- ArrayRef<AnyFunctionType::Param> params,
763
- ConstraintLocatorBuilder locator) {
759
+ ConstraintSystem::TypeMatchResult constraints::matchCallArguments (
760
+ ConstraintSystem &cs, ArrayRef<AnyFunctionType::Param> args,
761
+ ArrayRef<AnyFunctionType::Param> params, ConstraintLocatorBuilder locator) {
764
762
// Extract the parameters.
765
763
ValueDecl *callee;
766
764
unsigned calleeLevel;
@@ -821,6 +819,15 @@ constraints::matchCallArguments(ConstraintSystem &cs, bool isOperator,
821
819
// Check the argument types for each of the parameters.
822
820
ConstraintSystem::TypeMatchOptions subflags =
823
821
ConstraintSystem::TMF_GenerateConstraints;
822
+
823
+ // If this application is part of an operator, then we allow an implicit
824
+ // lvalue to be compatible with inout arguments. This is used by
825
+ // assignment operators.
826
+ auto *anchor = locator.getAnchor ();
827
+ assert (anchor && " locator without anchor expression?" );
828
+ bool isOperator = (isa<PrefixUnaryExpr>(anchor) ||
829
+ isa<PostfixUnaryExpr>(anchor) || isa<BinaryExpr>(anchor));
830
+
824
831
ConstraintKind subKind = (isOperator
825
832
? ConstraintKind::OperatorArgumentConversion
826
833
: ConstraintKind::ArgumentConversion);
@@ -841,15 +848,6 @@ constraints::matchCallArguments(ConstraintSystem &cs, bool isOperator,
841
848
getApplyArgToParam (argIdx,
842
849
paramIdx));
843
850
auto argTy = argsWithLabels[argIdx].getOldType ();
844
-
845
- // FIXME: This should be revisited. If one of argTy or paramTy
846
- // is a type variable, matchTypes() will add a constraint, and
847
- // when the constraint is later solved, we will have lost the
848
- // value of 'subflags'.
849
- if (isOperator) {
850
- subflags |= ConstraintSystem::TMF_ApplyingOperatorParameter;
851
- }
852
-
853
851
auto result = cs.matchTypes (argTy, paramTy, subKind, subflags, loc);
854
852
if (result.isFailure ())
855
853
return result;
@@ -2196,11 +2194,9 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
2196
2194
ConversionRestrictionKind::InoutToPointer);
2197
2195
}
2198
2196
}
2199
-
2200
- if (!flags.contains (TMF_ApplyingOperatorParameter) &&
2201
- // Operators cannot use these implicit conversions.
2202
- kind == ConstraintKind::ArgumentConversion) {
2203
2197
2198
+ // Operators cannot use these implicit conversions.
2199
+ if (kind == ConstraintKind::ArgumentConversion) {
2204
2200
// We can potentially convert from an UnsafeMutablePointer
2205
2201
// of a different type, if we're a void pointer.
2206
2202
Type unwrappedType1 = type1;
@@ -3846,7 +3842,6 @@ ConstraintSystem::simplifyBridgingConstraint(Type type1,
3846
3842
3847
3843
// Explicit bridging from a value type to an Objective-C class type.
3848
3844
if (unwrappedFromType->isPotentiallyBridgedValueType () &&
3849
- !flags.contains (TMF_ApplyingOperatorParameter) &&
3850
3845
(unwrappedToType->isBridgeableObjectType () ||
3851
3846
(unwrappedToType->isExistentialType () &&
3852
3847
!unwrappedToType->isAny ()))) {
@@ -4450,19 +4445,11 @@ ConstraintSystem::simplifyApplicableFnConstraint(
4450
4445
// For a function, bind the output and convert the argument to the input.
4451
4446
auto func1 = type1->castTo <FunctionType>();
4452
4447
if (auto func2 = dyn_cast<FunctionType>(desugar2)) {
4453
- // If this application is part of an operator, then we allow an implicit
4454
- // lvalue to be compatible with inout arguments. This is used by
4455
- // assignment operators.
4456
- bool isOperator = (isa<PrefixUnaryExpr>(anchor) ||
4457
- isa<PostfixUnaryExpr>(anchor) ||
4458
- isa<BinaryExpr>(anchor));
4459
-
4460
4448
// The argument type must be convertible to the input type.
4461
- if (::matchCallArguments (*this , isOperator,
4462
- func1->getParams (),
4463
- func2->getParams (),
4464
- outerLocator.withPathElement (
4465
- ConstraintLocator::ApplyArgument)).isFailure ())
4449
+ if (::matchCallArguments (
4450
+ *this , func1->getParams (), func2->getParams (),
4451
+ outerLocator.withPathElement (ConstraintLocator::ApplyArgument))
4452
+ .isFailure ())
4466
4453
return SolutionKind::Error;
4467
4454
4468
4455
// The result types are equivalent.
@@ -4565,12 +4552,6 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
4565
4552
return SolutionKind::Unsolved;
4566
4553
};
4567
4554
4568
- // We'll apply user conversions for operator arguments at the application
4569
- // site.
4570
- if (matchKind == ConstraintKind::OperatorArgumentConversion) {
4571
- flags |= TMF_ApplyingOperatorParameter;
4572
- }
4573
-
4574
4555
TypeMatchOptions subflags = getDefaultDecompositionOptions (flags);
4575
4556
4576
4557
switch (restriction) {
0 commit comments