@@ -1425,22 +1425,17 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
1425
1425
if (typeVarOccursInType (typeVar1, type2))
1426
1426
return formUnsolvedResult ();
1427
1427
1428
- // Equal constraints allow mixed LValue/RValue bindings.
1428
+ // Equal constraints allow mixed LValue/RValue bindings, but
1429
+ // if we bind a type to a type variable that can bind to
1430
+ // LValues as part of simplifying the Equal constraint we may
1431
+ // later block a binding of the opposite "LValue-ness" to the
1432
+ // same type variable that happens as part of simplifying
1433
+ // another constraint.
1429
1434
if (kind == ConstraintKind::Equal) {
1430
- // If we could bind an LValue to the type variable, but the
1431
- // type that is already bound is not an LValue, defer
1432
- // simplifying the constraint since we may come along at a
1433
- // later time and attempt to bind the LValue type to this
1434
- // type variable.
1435
- if (typeVar1->getImpl ().canBindToLValue ()) {
1436
- if (!type2->isLValueType ()) {
1437
- return formUnsolvedResult ();
1438
- }
1439
- } else {
1440
- // If the type variable does not allow LValue bindings,
1441
- // get the RValue type.
1442
- type2 = type2->getRValueType ();
1443
- }
1435
+ if (typeVar1->getImpl ().canBindToLValue ())
1436
+ return formUnsolvedResult ();
1437
+
1438
+ type2 = type2->getRValueType ();
1444
1439
}
1445
1440
1446
1441
// If the left-hand type variable cannot bind to an lvalue,
@@ -1480,22 +1475,17 @@ ConstraintSystem::matchTypes(Type type1, Type type2, ConstraintKind kind,
1480
1475
if (typeVarOccursInType (typeVar2, type1))
1481
1476
return formUnsolvedResult ();
1482
1477
1483
- // Equal constraints allow mixed LValue/RValue bindings.
1478
+ // Equal constraints allow mixed LValue/RValue bindings, but
1479
+ // if we bind a type to a type variable that can bind to
1480
+ // LValues as part of simplifying the Equal constraint we may
1481
+ // later block a binding of the opposite "LValue-ness" to the
1482
+ // same type variable that happens as part of simplifying
1483
+ // another constraint.
1484
1484
if (kind == ConstraintKind::Equal) {
1485
- // If we could bind an LValue to the type variable, but the
1486
- // type that is already bound is not an LValue, defer
1487
- // simplifying the constraint since we may come along at a
1488
- // later time and attempt to bind the LValue type to this
1489
- // type variable.
1490
- if (typeVar2->getImpl ().canBindToLValue ()) {
1491
- if (!type1->isLValueType ()) {
1492
- return formUnsolvedResult ();
1493
- }
1494
- } else {
1495
- // If the type variable does not allow LValue bindings,
1496
- // get the RValue type.
1497
- type1 = type1->getRValueType ();
1498
- }
1485
+ if (typeVar2->getImpl ().canBindToLValue ())
1486
+ return formUnsolvedResult ();
1487
+
1488
+ type1 = type1->getRValueType ();
1499
1489
}
1500
1490
1501
1491
if (!typeVar2->getImpl ().canBindToLValue () &&
0 commit comments