@@ -123,10 +123,10 @@ ConstraintLocator *Solution::getCalleeLocator(ConstraintLocator *locator,
123
123
}
124
124
125
125
ConstraintLocator *
126
- Solution::getConstraintLocator (const Expr * anchor,
126
+ Solution::getConstraintLocator (TypedNode anchor,
127
127
ArrayRef<LocatorPathElt> path) const {
128
128
auto &cs = getConstraintSystem ();
129
- return cs.getConstraintLocator (const_cast <Expr *>( anchor) , path);
129
+ return cs.getConstraintLocator (anchor, path);
130
130
}
131
131
132
132
ConstraintLocator *
@@ -1204,9 +1204,9 @@ namespace {
1204
1204
// For properties, build member references.
1205
1205
if (isa<VarDecl>(member)) {
1206
1206
if (isUnboundInstanceMember) {
1207
- assert (memberLocator.getBaseLocator () &&
1207
+ assert (memberLocator.getBaseLocator () &&
1208
1208
cs.UnevaluatedRootExprs .count (
1209
- memberLocator.getBaseLocator ()->getAnchor ()) &&
1209
+ getAsExpr ( memberLocator.getBaseLocator ()->getAnchor () )) &&
1210
1210
" Attempt to reference an instance member of a metatype" );
1211
1211
auto baseInstanceTy = cs.getType (base)
1212
1212
->getInOutObjectType ()->getMetatypeInstanceType ();
@@ -1618,7 +1618,7 @@ namespace {
1618
1618
1619
1619
if (selected.choice .getKind () ==
1620
1620
OverloadChoiceKind::KeyPathDynamicMemberLookup &&
1621
- !isa <SubscriptExpr>(locator.getAnchor ()))
1621
+ !isExpr <SubscriptExpr>(locator.getAnchor ()))
1622
1622
locatorKind = ConstraintLocator::Member;
1623
1623
1624
1624
newSubscript =
@@ -1744,7 +1744,7 @@ namespace {
1744
1744
locatorKind = ConstraintLocator::Member;
1745
1745
1746
1746
if (choice.getKind () == OverloadChoiceKind::KeyPathDynamicMemberLookup) {
1747
- locatorKind = isa <SubscriptExpr>(locator.getAnchor ())
1747
+ locatorKind = isExpr <SubscriptExpr>(locator.getAnchor ())
1748
1748
? ConstraintLocator::SubscriptMember
1749
1749
: ConstraintLocator::Member;
1750
1750
}
@@ -1898,7 +1898,7 @@ namespace {
1898
1898
SourceLoc dotLoc,
1899
1899
ConstraintLocator *memberLoc) {
1900
1900
auto &ctx = cs.getASTContext ();
1901
- auto *anchor = memberLoc->getAnchor ();
1901
+ auto *anchor = getAsExpr ( memberLoc->getAnchor () );
1902
1902
1903
1903
SmallVector<KeyPathExpr::Component, 2 > components;
1904
1904
@@ -7804,13 +7804,13 @@ namespace {
7804
7804
explicit CompareExprSourceLocs (SourceManager &sourceMgr)
7805
7805
: sourceMgr(sourceMgr) { }
7806
7806
7807
- bool operator ()(Expr * lhs, Expr * rhs) const {
7807
+ bool operator ()(TypedNode lhs, TypedNode rhs) const {
7808
7808
if (static_cast <bool >(lhs) != static_cast <bool >(rhs)) {
7809
7809
return static_cast <bool >(lhs);
7810
7810
}
7811
7811
7812
- auto lhsLoc = lhs-> getLoc ();
7813
- auto rhsLoc = rhs-> getLoc ();
7812
+ auto lhsLoc = getLoc (lhs );
7813
+ auto rhsLoc = getLoc (rhs );
7814
7814
if (lhsLoc.isValid () != rhsLoc.isValid ())
7815
7815
return lhsLoc.isValid ();
7816
7816
@@ -7824,26 +7824,27 @@ namespace {
7824
7824
// / able to emit an error message, or false if none of the fixits worked out.
7825
7825
bool ConstraintSystem::applySolutionFixes (const Solution &solution) {
7826
7826
// / Collect the fixes on a per-expression basis.
7827
- llvm::SmallDenseMap<Expr *, SmallVector<ConstraintFix *, 4 >> fixesPerExpr;
7827
+ llvm::SmallDenseMap<TypedNode, SmallVector<ConstraintFix *, 4 >>
7828
+ fixesPerAnchor;
7828
7829
for (auto *fix : solution.Fixes ) {
7829
- fixesPerExpr [fix->getAnchor ()].push_back (fix);
7830
+ fixesPerAnchor [fix->getAnchor ()].push_back (fix);
7830
7831
}
7831
7832
7832
7833
// Collect all of the expressions that have fixes, and sort them by
7833
7834
// source ordering.
7834
- SmallVector<Expr * , 4 > exprsWithFixes ;
7835
- for (const auto &fix : fixesPerExpr ) {
7836
- exprsWithFixes .push_back (fix.getFirst ());
7835
+ SmallVector<TypedNode , 4 > orderedAnchors ;
7836
+ for (const auto &fix : fixesPerAnchor ) {
7837
+ orderedAnchors .push_back (fix.getFirst ());
7837
7838
}
7838
- std::sort (exprsWithFixes .begin (), exprsWithFixes .end (),
7839
+ std::sort (orderedAnchors .begin (), orderedAnchors .end (),
7839
7840
CompareExprSourceLocs (Context.SourceMgr ));
7840
7841
7841
7842
// Walk over each of the expressions, diagnosing fixes.
7842
7843
bool diagnosedAnyErrors = false ;
7843
7844
7844
- for (auto expr : exprsWithFixes ) {
7845
+ for (auto anchor : orderedAnchors ) {
7845
7846
// Coalesce fixes with the same locator to avoid duplicating notes.
7846
- auto fixes = fixesPerExpr[expr ];
7847
+ auto fixes = fixesPerAnchor[anchor ];
7847
7848
7848
7849
using ConstraintFixVector = llvm::SmallVector<ConstraintFix *, 4 >;
7849
7850
llvm::SmallMapVector<ConstraintLocator *,
0 commit comments