@@ -551,8 +551,7 @@ class BuilderClosureVisitor
551
551
return nullptr ;
552
552
}
553
553
554
- // FIXME: Need a locator for the "if" statement.
555
- Type resultType = cs->addJoinConstraint (nullptr ,
554
+ Type resultType = cs->addJoinConstraint (cs->getConstraintLocator (ifStmt),
556
555
{
557
556
{ cs->getType (thenExpr), cs->getConstraintLocator (thenExpr) },
558
557
{ cs->getType (elseExpr), cs->getConstraintLocator (elseExpr) }
@@ -709,8 +708,8 @@ class BuilderClosureVisitor
709
708
}
710
709
711
710
// Form the type of the switch itself.
712
- // FIXME: Need a locator for the "switch" statement.
713
- Type resultType = cs->addJoinConstraint ( nullptr , injectedCaseTerms);
711
+ Type resultType = cs-> addJoinConstraint (
712
+ cs->getConstraintLocator (switchStmt) , injectedCaseTerms);
714
713
if (!resultType) {
715
714
hadError = true ;
716
715
return nullptr ;
@@ -810,7 +809,8 @@ class BuilderClosureVisitor
810
809
}
811
810
cs->addConstraint (
812
811
ConstraintKind::Equal, cs->getType (arrayInitExpr), arrayType,
813
- cs->getConstraintLocator (arrayInitExpr));
812
+ cs->getConstraintLocator (
813
+ arrayInitExpr, LocatorPathElt::ContextualType ()));
814
814
815
815
// Form a call to Array.append(_:) to add the result of executing each
816
816
// iteration of the loop body to the array formed above.
@@ -1477,32 +1477,10 @@ Optional<BraceStmt *> TypeChecker::applyFunctionBuilderBodyTransform(
1477
1477
// Build a constraint system in which we can check the body of the function.
1478
1478
ConstraintSystem cs (func, options);
1479
1479
1480
- // Find an expression... any expression... to use for a locator.
1481
- // FIXME: This is a hack because we don't have the notion of locators that
1482
- // refer to statements.
1483
- Expr *fakeAnchor = nullptr ;
1484
- {
1485
- class FindExprWalker : public ASTWalker {
1486
- Expr *&fakeAnchor;
1487
-
1488
- public:
1489
- explicit FindExprWalker (Expr *&fakeAnchor) : fakeAnchor(fakeAnchor) { }
1490
-
1491
- std::pair<bool , Expr *> walkToExprPre (Expr *E) {
1492
- if (!fakeAnchor)
1493
- fakeAnchor = E;
1494
-
1495
- return { false , nullptr };
1496
- }
1497
- } walker (fakeAnchor);
1498
-
1499
- func->getBody ()->walk (walker);
1500
- }
1501
-
1502
1480
if (auto result = cs.matchFunctionBuilder (
1503
1481
func, builderType, resultContextType, resultConstraintKind,
1504
- /* calleeLocator= */ cs.getConstraintLocator (fakeAnchor ),
1505
- /* FIXME: */ cs.getConstraintLocator (fakeAnchor ))) {
1482
+ cs.getConstraintLocator (func-> getBody () ),
1483
+ cs.getConstraintLocator (func-> getBody () ))) {
1506
1484
if (result->isFailure ())
1507
1485
return nullptr ;
1508
1486
}
0 commit comments