@@ -1347,9 +1347,9 @@ namespace bolt {
1347
1347
return Constraint->Source ;
1348
1348
}
1349
1349
1350
- bool unify (Type* A, Type* B, bool DidSwap);
1350
+ bool unifyField (Type* A, Type* B, bool DidSwap);
1351
1351
1352
- bool unifyField (Type* A, Type* B);
1352
+ bool unify (Type* A, Type* B, bool DidSwap );
1353
1353
1354
1354
bool unify () {
1355
1355
return unify (Constraint->Left , Constraint->Right , false );
@@ -1468,6 +1468,24 @@ namespace bolt {
1468
1468
1469
1469
};
1470
1470
1471
+ bool Unifier::unifyField (Type* A, Type* B, bool DidSwap) {
1472
+ if (llvm::isa<TAbsent>(A) && llvm::isa<TAbsent>(B)) {
1473
+ return true ;
1474
+ }
1475
+ if (llvm::isa<TAbsent>(B)) {
1476
+ std::swap (A, B);
1477
+ DidSwap = !DidSwap;
1478
+ }
1479
+ if (llvm::isa<TAbsent>(A)) {
1480
+ auto Present = static_cast <TPresent*>(B);
1481
+ C.DE .add <FieldNotFoundDiagnostic>(CurrentFieldName, C.simplifyType (getLeft ()), LeftPath, getSource ());
1482
+ return false ;
1483
+ }
1484
+ auto Present1 = static_cast <TPresent*>(A);
1485
+ auto Present2 = static_cast <TPresent*>(B);
1486
+ return unify (Present1->Ty , Present2->Ty , DidSwap);
1487
+ };
1488
+
1471
1489
bool Unifier::unify (Type* A, Type* B, bool DidSwap) {
1472
1490
1473
1491
A = C.simplifyType (A);
@@ -1520,23 +1538,6 @@ namespace bolt {
1520
1538
DidSwap = !DidSwap;
1521
1539
};
1522
1540
1523
- auto unifyField = [&](Type* A, Type* B) {
1524
- if (llvm::isa<TAbsent>(A) && llvm::isa<TAbsent>(B)) {
1525
- return true ;
1526
- }
1527
- if (llvm::isa<TAbsent>(B)) {
1528
- swap ();
1529
- }
1530
- if (llvm::isa<TAbsent>(A)) {
1531
- auto Present = static_cast <TPresent*>(B);
1532
- C.DE .add <FieldNotFoundDiagnostic>(CurrentFieldName, C.simplifyType (getLeft ()), LeftPath, getSource ());
1533
- return false ;
1534
- }
1535
- auto Present1 = static_cast <TPresent*>(A);
1536
- auto Present2 = static_cast <TPresent*>(B);
1537
- return unify (Present1->Ty , Present2->Ty , DidSwap);
1538
- };
1539
-
1540
1541
if (llvm::isa<TVar>(A) && llvm::isa<TVar>(B)) {
1541
1542
auto Var1 = static_cast <TVar*>(A);
1542
1543
auto Var2 = static_cast <TVar*>(B);
@@ -1706,7 +1707,7 @@ namespace bolt {
1706
1707
LeftPath.push_back (TypeIndex::forFieldType ());
1707
1708
RightPath.push_back (TypeIndex::forFieldType ());
1708
1709
CurrentFieldName = Field1->Name ;
1709
- if (!unifyField (Field1->Ty , Field2->Ty )) {
1710
+ if (!unifyField (Field1->Ty , Field2->Ty , DidSwap )) {
1710
1711
Success = false ;
1711
1712
}
1712
1713
LeftPath.pop_back ();
@@ -1743,7 +1744,7 @@ namespace bolt {
1743
1744
bool Success = true ;
1744
1745
pushLeft (TypeIndex::forFieldType ());
1745
1746
CurrentFieldName = Field->Name ;
1746
- if (!unifyField (Field->Ty , new TAbsent)) {
1747
+ if (!unifyField (Field->Ty , new TAbsent, DidSwap )) {
1747
1748
Success = false ;
1748
1749
}
1749
1750
popLeft ();
0 commit comments