@@ -3748,7 +3748,12 @@ bool ConstraintSystem::repairFailures(
3748
3748
// a property with a function type or a method reference,
3749
3749
// e.g. `foo.bar = 42` neither can be used if the destination
3750
3750
// is not l-value.
3751
- if (!getType (destExpr)->is <LValueType>() && rhs->is <FunctionType>()) {
3751
+ auto destType = getType (destExpr);
3752
+ auto destTypeVar = destType->getAs <TypeVariableType>();
3753
+ bool destIsOrCanBindToLValue =
3754
+ destType->is <LValueType>() ||
3755
+ (destTypeVar && destTypeVar->getImpl ().canBindToLValue ());
3756
+ if (!destIsOrCanBindToLValue && rhs->is <FunctionType>()) {
3752
3757
conversionsOrFixes.push_back (
3753
3758
TreatRValueAsLValue::create (*this , getConstraintLocator (locator)));
3754
3759
return true ;
@@ -3772,9 +3777,9 @@ bool ConstraintSystem::repairFailures(
3772
3777
TMF_ApplyingFix, locator);
3773
3778
3774
3779
auto *loc = getConstraintLocator (locator);
3775
- if (getType (destExpr)-> is <LValueType>() || result.isFailure ()) {
3776
- // Let this asignment failure be diagnosed by the AllowTupleTypeMismatch
3777
- // fix already recorded.
3780
+ if (destIsOrCanBindToLValue || result.isFailure ()) {
3781
+ // Let this assignment failure be diagnosed by the
3782
+ // AllowTupleTypeMismatch fix already recorded.
3778
3783
if (hasFixFor (loc, FixKind::AllowTupleTypeMismatch))
3779
3784
return true ;
3780
3785
0 commit comments