Skip to content

Commit 9347a09

Browse files
committed
[ConstraintSystem] Adjust getCalleeLocator and simplifyLocator to handle ArgumentAttribute
- `getCalleeLocator`, if given locator ends at `ArgumentAttribute` strip the last element which makes sure that produced locator always refers directly to argument-to-parameter conversion. - `simplifyLocator`, always leave `ArgumentAttribute` in the path because it's useful for diagnostics.
1 parent 3efa052 commit 9347a09

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ ConstraintLocator *ConstraintSystem::getCalleeLocator(
462462
return getConstraintLocator(anchor, LocatorPathElt::ApplyFunction());
463463
}
464464

465+
if (locator->isLastElement<LocatorPathElt::ArgumentAttribute>()) {
466+
return getConstraintLocator(anchor, path.drop_back());
467+
}
468+
465469
// If we have a locator that starts with a key path component element, we
466470
// may have a callee given by a property or subscript component.
467471
if (auto componentElt =
@@ -3527,6 +3531,13 @@ void constraints::simplifyLocator(ASTNode &anchor,
35273531
continue;
35283532
}
35293533

3534+
case ConstraintLocator::ArgumentAttribute: {
3535+
// At this point we should have already found argument expression
3536+
// this attribute belogs to, so we can leave this element in place
3537+
// because it points out exact location useful for diagnostics.
3538+
break;
3539+
}
3540+
35303541
default:
35313542
// FIXME: Lots of other cases to handle.
35323543
break;

0 commit comments

Comments
 (0)