@@ -132,8 +132,7 @@ FailureDiagnostic::getArgumentListExprFor(ConstraintLocator *locator) const {
132
132
// Form a new locator that ends at the ApplyArgument element, then simplify
133
133
// to get the argument list.
134
134
auto newPath = ArrayRef<LocatorPathElt>(path.begin (), iter + 1 );
135
- auto &cs = getConstraintSystem ();
136
- auto argListLoc = cs.getConstraintLocator (locator->getAnchor (), newPath);
135
+ auto argListLoc = getConstraintLocator (locator->getAnchor (), newPath);
137
136
return simplifyLocatorToAnchor (argListLoc);
138
137
}
139
138
@@ -218,8 +217,7 @@ ProtocolConformance *RequirementFailure::getConformanceForConditionalReq(
218
217
return nullptr ;
219
218
220
219
auto path = locator->getPath ();
221
- auto *typeReqLoc = getConstraintLocator (getRawAnchor ().get <const Expr *>(),
222
- path.drop_back ());
220
+ auto *typeReqLoc = getConstraintLocator (getRawAnchor (), path.drop_back ());
223
221
224
222
auto result = llvm::find_if (
225
223
cs.CheckedConformances ,
@@ -1733,7 +1731,6 @@ bool AssignmentFailure::diagnoseAsError() {
1733
1731
1734
1732
std::pair<Expr *, Optional<OverloadChoice>>
1735
1733
AssignmentFailure::resolveImmutableBase (Expr *expr) const {
1736
- auto &cs = getConstraintSystem ();
1737
1734
auto *DC = getDC ();
1738
1735
expr = expr->getValueProvidingExpr ();
1739
1736
@@ -1763,7 +1760,7 @@ AssignmentFailure::resolveImmutableBase(Expr *expr) const {
1763
1760
}
1764
1761
1765
1762
Optional<OverloadChoice> member = getMemberRef (
1766
- cs. getConstraintLocator (SE, ConstraintLocator::SubscriptMember));
1763
+ getConstraintLocator (SE, ConstraintLocator::SubscriptMember));
1767
1764
1768
1765
// If it isn't settable, return it.
1769
1766
if (member) {
@@ -1798,7 +1795,7 @@ AssignmentFailure::resolveImmutableBase(Expr *expr) const {
1798
1795
// Look through property references.
1799
1796
if (auto *UDE = dyn_cast<UnresolvedDotExpr>(expr)) {
1800
1797
// If we found a decl for the UDE, check it.
1801
- auto loc = cs. getConstraintLocator (UDE, ConstraintLocator::Member);
1798
+ auto loc = getConstraintLocator (UDE, ConstraintLocator::Member);
1802
1799
1803
1800
auto member = getMemberRef (loc);
1804
1801
@@ -1864,15 +1861,14 @@ AssignmentFailure::getMemberRef(ConstraintLocator *locator) const {
1864
1861
// If this is a keypath dynamic member lookup, we have to
1865
1862
// adjust the locator to find member referred by it.
1866
1863
if (isValidKeyPathDynamicMemberLookup (subscript)) {
1867
- auto &cs = getConstraintSystem ();
1868
1864
// Type has a following format:
1869
1865
// `(Self) -> (dynamicMember: {Writable}KeyPath<T, U>) -> U`
1870
1866
auto *fullType = member->openedFullType ->castTo <FunctionType>();
1871
1867
auto *fnType = fullType->getResult ()->castTo <FunctionType>();
1872
1868
1873
1869
auto paramTy = fnType->getParams ()[0 ].getPlainType ();
1874
1870
auto keyPath = paramTy->getAnyNominal ();
1875
- auto memberLoc = cs. getConstraintLocator (
1871
+ auto memberLoc = getConstraintLocator (
1876
1872
locator, LocatorPathElt::KeyPathDynamicMember (keyPath));
1877
1873
1878
1874
auto memberRef = getOverloadChoiceIfAvailable (memberLoc);
@@ -2025,7 +2021,7 @@ bool ContextualFailure::diagnoseAsError() {
2025
2021
auto &cs = getConstraintSystem ();
2026
2022
MissingOptionalUnwrapFailure failure (getSolution (), getType (anchor),
2027
2023
toType,
2028
- cs. getConstraintLocator (anchor));
2024
+ getConstraintLocator (anchor));
2029
2025
if (failure.diagnoseAsError ())
2030
2026
return true ;
2031
2027
}
@@ -3095,8 +3091,7 @@ bool MissingCallFailure::diagnoseAsError() {
3095
3091
}
3096
3092
3097
3093
case ConstraintLocator::AutoclosureResult: {
3098
- auto loc = getConstraintLocator (getRawAnchor ().get <const Expr *>(),
3099
- path.drop_back ());
3094
+ auto loc = getConstraintLocator (getRawAnchor (), path.drop_back ());
3100
3095
AutoClosureForwardingFailure failure (getSolution (), loc);
3101
3096
return failure.diagnoseAsError ();
3102
3097
}
@@ -3517,15 +3512,14 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3517
3512
}
3518
3513
3519
3514
auto isCallArgument = [this ](Expr *expr) {
3520
- auto &cs = getConstraintSystem ();
3521
- auto argExpr = cs.getParentExpr (expr);
3515
+ auto argExpr = findParentExpr (expr);
3522
3516
if (!argExpr)
3523
3517
return false ;
3524
- auto possibleApplyExpr = cs. getParentExpr (expr);
3518
+ auto possibleApplyExpr = findParentExpr (expr);
3525
3519
return possibleApplyExpr && isa<ApplyExpr>(possibleApplyExpr);
3526
3520
};
3527
3521
3528
- auto *initCall = cs. getParentExpr (cs. getParentExpr (ctorRef));
3522
+ auto *initCall = findParentExpr ( findParentExpr (ctorRef));
3529
3523
3530
3524
auto isMutable = [&DC](ValueDecl *decl) {
3531
3525
if (auto *storage = dyn_cast<AbstractStorageDecl>(decl))
@@ -3534,7 +3528,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3534
3528
return true ;
3535
3529
};
3536
3530
3537
- auto *baseLoc = cs. getConstraintLocator (ctorRef->getBase ());
3531
+ auto *baseLoc = getConstraintLocator (ctorRef->getBase ());
3538
3532
if (auto selection = getCalleeOverloadChoiceIfAvailable (baseLoc)) {
3539
3533
OverloadChoice choice = selection->choice ;
3540
3534
if (choice.isDecl () && isMutable (choice.getDecl ()) &&
@@ -3563,8 +3557,8 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3563
3557
}
3564
3558
3565
3559
if (getRawAnchor () &&
3566
- cs. DC ->getContextKind () == DeclContextKind::Initializer) {
3567
- auto *TypeDC = cs. DC ->getParent ();
3560
+ getDC () ->getContextKind () == DeclContextKind::Initializer) {
3561
+ auto *TypeDC = getDC () ->getParent ();
3568
3562
bool propertyInitializer = true ;
3569
3563
// If the parent context is not a type context, we expect it
3570
3564
// to be a defaulted parameter in a function declaration.
@@ -3785,13 +3779,13 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
3785
3779
3786
3780
bool PartialApplicationFailure::diagnoseAsError () {
3787
3781
auto &cs = getConstraintSystem ();
3788
- auto * anchor = cast<UnresolvedDotExpr>(getRawAnchor ().get <const Expr *>());
3782
+ auto anchor = cast<UnresolvedDotExpr>(getRawAnchor ().get <const Expr *>());
3789
3783
3790
3784
RefKind kind = RefKind::MutatingMethod;
3791
3785
3792
3786
// If this is initializer delegation chain, we have a tailored message.
3793
- if (getOverloadChoiceIfAvailable (cs. getConstraintLocator (
3794
- anchor, ConstraintLocator::ConstructorMember))) {
3787
+ if (getOverloadChoiceIfAvailable (
3788
+ getConstraintLocator ( anchor, ConstraintLocator::ConstructorMember))) {
3795
3789
kind = anchor->getBase ()->isSuperExpr () ? RefKind::SuperInit
3796
3790
: RefKind::SelfInit;
3797
3791
} else if (anchor->getBase ()->isSuperExpr ()) {
@@ -4763,8 +4757,7 @@ bool InaccessibleMemberFailure::diagnoseAsError() {
4763
4757
4764
4758
if (baseExpr) {
4765
4759
auto &cs = getConstraintSystem ();
4766
- auto *locator =
4767
- cs.getConstraintLocator (baseExpr, ConstraintLocator::Member);
4760
+ auto *locator = getConstraintLocator (baseExpr, ConstraintLocator::Member);
4768
4761
if (cs.hasFixFor (locator))
4769
4762
return false ;
4770
4763
}
@@ -5590,7 +5583,7 @@ bool ArgumentMismatchFailure::diagnoseUseOfReferenceEqualityOperator() const {
5590
5583
// one would cover both arguments.
5591
5584
if (getAnchor ().get <const Expr *>() == rhs && rhsType->is <FunctionType>()) {
5592
5585
auto &cs = getConstraintSystem ();
5593
- if (cs.hasFixFor (cs. getConstraintLocator (
5586
+ if (cs.hasFixFor (getConstraintLocator (
5594
5587
binaryOp, {ConstraintLocator::ApplyArgument,
5595
5588
LocatorPathElt::ApplyArgToParam (
5596
5589
0 , 0 , getParameterFlagsAtIndex (0 ))})))
@@ -5720,7 +5713,7 @@ bool ArgumentMismatchFailure::diagnoseMisplacedMissingArgument() const {
5720
5713
auto *fnType = getFnType ();
5721
5714
const auto ¶m = fnType->getParams ()[0 ];
5722
5715
5723
- auto * anchor = getRawAnchor (). get < const Expr *> ();
5716
+ auto anchor = getRawAnchor ();
5724
5717
5725
5718
MissingArgumentsFailure failure (
5726
5719
solution, {std::make_pair (0 , param)},
@@ -5802,8 +5795,8 @@ bool ExtraneousCallFailure::diagnoseAsError() {
5802
5795
// If this is something like `foo()` where `foo` is a variable
5803
5796
// or a property, let's suggest dropping `()`.
5804
5797
auto removeParensFixIt = [&](InFlightDiagnostic &diagnostic) {
5805
- auto *argLoc = getConstraintLocator ( getRawAnchor (). get < const Expr *>(),
5806
- ConstraintLocator::ApplyArgument);
5798
+ auto *argLoc =
5799
+ getConstraintLocator ( getRawAnchor (), ConstraintLocator::ApplyArgument);
5807
5800
5808
5801
if (auto *TE =
5809
5802
dyn_cast_or_null<TupleExpr>(simplifyLocatorToAnchor (argLoc))) {
@@ -6098,7 +6091,7 @@ bool AssignmentTypeMismatchFailure::diagnoseAsError() {
6098
6091
}
6099
6092
6100
6093
bool AssignmentTypeMismatchFailure::diagnoseAsNote () {
6101
- auto * anchor = getAnchor (). get < const Expr *> ();
6094
+ auto anchor = getAnchor ();
6102
6095
6103
6096
if (auto overload =
6104
6097
getCalleeOverloadChoiceIfAvailable (getConstraintLocator (anchor))) {
0 commit comments