@@ -52,16 +52,20 @@ bool FailureDiagnostic::diagnoseAsNote() {
52
52
}
53
53
54
54
ASTNode FailureDiagnostic::getAnchor () const {
55
- auto &cs = getConstraintSystem ();
56
-
57
55
auto *locator = getLocator ();
58
56
// Resolve the locator to a specific expression.
59
- SourceRange range;
60
- ConstraintLocator *resolved = simplifyLocator (cs, locator, range);
61
- if (!resolved || !resolved->getAnchor ())
62
- return locator->getAnchor ();
63
57
64
- auto anchor = resolved->getAnchor ();
58
+ auto anchor = locator->getAnchor ();
59
+
60
+ {
61
+ SourceRange range;
62
+ auto path = locator->getPath ();
63
+
64
+ simplifyLocator (anchor, path, range);
65
+ if (!anchor)
66
+ return locator->getAnchor ();
67
+ }
68
+
65
69
// FIXME: Work around an odd locator representation that doesn't separate the
66
70
// base of a subscript member from the member access.
67
71
if (locator->isLastElement <LocatorPathElt::SubscriptMember>()) {
@@ -3148,12 +3152,18 @@ bool MissingPropertyWrapperUnwrapFailure::diagnoseAsError() {
3148
3152
}
3149
3153
3150
3154
bool SubscriptMisuseFailure::diagnoseAsError () {
3155
+ auto *locator = getLocator ();
3151
3156
auto &sourceMgr = getASTContext ().SourceMgr ;
3152
3157
3153
3158
auto *memberExpr = castToExpr<UnresolvedDotExpr>(getRawAnchor ());
3154
3159
3155
3160
auto memberRange = getSourceRange ();
3156
- (void )simplifyLocator (getConstraintSystem (), getLocator (), memberRange);
3161
+
3162
+ {
3163
+ auto rawAnchor = getRawAnchor ();
3164
+ auto path = locator->getPath ();
3165
+ simplifyLocator (rawAnchor, path, memberRange);
3166
+ }
3157
3167
3158
3168
auto nameLoc = DeclNameLoc (memberRange.Start );
3159
3169
@@ -3183,7 +3193,7 @@ bool SubscriptMisuseFailure::diagnoseAsError() {
3183
3193
}
3184
3194
diag.flush ();
3185
3195
3186
- if (auto overload = getOverloadChoiceIfAvailable (getLocator () )) {
3196
+ if (auto overload = getOverloadChoiceIfAvailable (locator )) {
3187
3197
emitDiagnosticAt (overload->choice .getDecl (), diag::kind_declared_here,
3188
3198
DescriptiveDeclKind::Subscript);
3189
3199
}
0 commit comments