@@ -415,7 +415,8 @@ ConstraintLocator *ConstraintSystem::getConstraintLocator(
415
415
}
416
416
417
417
ConstraintLocator *
418
- ConstraintSystem::getCalleeLocator (ConstraintLocator *locator) {
418
+ ConstraintSystem::getCalleeLocator (ConstraintLocator *locator,
419
+ bool lookThroughApply) {
419
420
auto *anchor = locator->getAnchor ();
420
421
assert (anchor && " Expected an anchor!" );
421
422
@@ -456,26 +457,28 @@ ConstraintSystem::getCalleeLocator(ConstraintLocator *locator) {
456
457
if (isa<SubscriptExpr>(anchor))
457
458
return getConstraintLocator (anchor, ConstraintLocator::SubscriptMember);
458
459
459
- if (auto *applyExpr = dyn_cast<ApplyExpr>(anchor)) {
460
- auto *fnExpr = applyExpr->getFn ();
461
- // For an apply of a metatype, we have a short-form constructor. Unlike
462
- // other locators to callees, these are anchored on the apply expression
463
- // rather than the function expr.
464
- auto fnTy = getFixedTypeRecursive (getType (fnExpr), /* wantRValue*/ true );
465
- if (fnTy->is <AnyMetatypeType>()) {
466
- auto *fnLocator =
467
- getConstraintLocator (applyExpr, ConstraintLocator::ApplyFunction);
468
- return getConstraintLocator (fnLocator,
469
- ConstraintLocator::ConstructorMember);
470
- }
460
+ if (lookThroughApply) {
461
+ if (auto *applyExpr = dyn_cast<ApplyExpr>(anchor)) {
462
+ auto *fnExpr = applyExpr->getFn ();
463
+ // For an apply of a metatype, we have a short-form constructor. Unlike
464
+ // other locators to callees, these are anchored on the apply expression
465
+ // rather than the function expr.
466
+ auto fnTy = getFixedTypeRecursive (getType (fnExpr), /* wantRValue*/ true );
467
+ if (fnTy->is <AnyMetatypeType>()) {
468
+ auto *fnLocator =
469
+ getConstraintLocator (applyExpr, ConstraintLocator::ApplyFunction);
470
+ return getConstraintLocator (fnLocator,
471
+ ConstraintLocator::ConstructorMember);
472
+ }
471
473
472
- // Otherwise fall through and look for locators anchored on the function
473
- // expr. For CallExprs, this can look through things like parens and
474
- // optional chaining.
475
- if (auto *callExpr = dyn_cast<CallExpr>(anchor)) {
476
- anchor = callExpr->getDirectCallee ();
477
- } else {
478
- anchor = fnExpr;
474
+ // Otherwise fall through and look for locators anchored on the function
475
+ // expr. For CallExprs, this can look through things like parens and
476
+ // optional chaining.
477
+ if (auto *callExpr = dyn_cast<CallExpr>(anchor)) {
478
+ anchor = callExpr->getDirectCallee ();
479
+ } else {
480
+ anchor = fnExpr;
481
+ }
479
482
}
480
483
}
481
484
0 commit comments