@@ -1005,14 +1005,11 @@ class SyntacticElementConstraintGenerator
10051005 }
10061006
10071007 void visitSwitchStmt (SwitchStmt *switchStmt) {
1008- auto *switchLoc = cs.getConstraintLocator (
1009- locator, LocatorPathElt::SyntacticElement (switchStmt));
1010-
10111008 SmallVector<ElementInfo, 4 > elements;
10121009 {
10131010 auto *subjectExpr = switchStmt->getSubjectExpr ();
10141011 {
1015- elements.push_back (makeElement (subjectExpr, switchLoc ));
1012+ elements.push_back (makeElement (subjectExpr, locator ));
10161013
10171014 SyntacticElementTarget target (subjectExpr, context.getAsDeclContext (),
10181015 CTP_Unused, Type (),
@@ -1022,32 +1019,29 @@ class SyntacticElementConstraintGenerator
10221019 }
10231020
10241021 for (auto rawCase : switchStmt->getRawCases ())
1025- elements.push_back (makeElement (rawCase, switchLoc ));
1022+ elements.push_back (makeElement (rawCase, locator ));
10261023 }
10271024
1028- createConjunction (elements, switchLoc );
1025+ createConjunction (elements, locator );
10291026 }
10301027
10311028 void visitDoCatchStmt (DoCatchStmt *doStmt) {
1032- auto *doLoc = cs.getConstraintLocator (
1033- locator, LocatorPathElt::SyntacticElement (doStmt));
1034-
10351029 SmallVector<ElementInfo, 4 > elements;
10361030
10371031 // First, let's record a body of `do` statement. Note we need to add a
10381032 // SyntaticElement locator path element here to avoid treating the inner
10391033 // brace conjunction as being isolated if 'doLoc' is for an isolated
10401034 // conjunction (as is the case with 'do' expressions).
10411035 auto *doBodyLoc = cs.getConstraintLocator (
1042- doLoc , LocatorPathElt::SyntacticElement (doStmt->getBody ()));
1036+ locator , LocatorPathElt::SyntacticElement (doStmt->getBody ()));
10431037 elements.push_back (makeElement (doStmt->getBody (), doBodyLoc));
10441038
10451039 // After that has been type-checked, let's switch to
10461040 // individual `catch` statements.
10471041 for (auto *catchStmt : doStmt->getCatches ())
1048- elements.push_back (makeElement (catchStmt, doLoc ));
1042+ elements.push_back (makeElement (catchStmt, locator ));
10491043
1050- createConjunction (elements, doLoc );
1044+ createConjunction (elements, locator );
10511045 }
10521046
10531047 void visitCaseStmt (CaseStmt *caseStmt) {
@@ -1546,7 +1540,9 @@ bool ConstraintSystem::generateConstraints(SingleValueStmtExpr *E) {
15461540
15471541 // Generate the conjunction for the branches.
15481542 auto context = SyntacticElementContext::forSingleValueStmtExpr (E, join);
1549- SyntacticElementConstraintGenerator generator (*this , context, loc);
1543+ auto *stmtLoc =
1544+ getConstraintLocator (loc, LocatorPathElt::SyntacticElement (S));
1545+ SyntacticElementConstraintGenerator generator (*this , context, stmtLoc);
15501546 generator.visit (S);
15511547 return generator.hadError ;
15521548}
0 commit comments