Skip to content

Commit 5e6ad05

Browse files
committed
[CS] Don’t crash if locator passed to hasPreconcurrencyCallee has no anchor
When computing type relations of code completion items with respect to the context they are used in, we add a `ConstraintKind::Conversion` constraint with an empty constraint locator. This currently crashes in `hasPreconcurrencyCallee`. To fix this crash, just return `false` in these cases.
1 parent ab6faa9 commit 5e6ad05

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2657,7 +2657,11 @@ static bool fixExtraneousArguments(ConstraintSystem &cs,
26572657

26582658
bool ConstraintSystem::hasPreconcurrencyCallee(
26592659
ConstraintLocatorBuilder locator) {
2660-
auto calleeLocator = getCalleeLocator(getConstraintLocator(locator));
2660+
auto resolvedLocator = getConstraintLocator(locator);
2661+
if (resolvedLocator->getAnchor().isNull()) {
2662+
return false;
2663+
}
2664+
auto calleeLocator = getCalleeLocator(resolvedLocator);
26612665
auto calleeOverload = findSelectedOverloadFor(calleeLocator);
26622666
if (!calleeOverload || !calleeOverload->choice.isDecl())
26632667
return false;

0 commit comments

Comments
 (0)