Skip to content

Commit c05abfe

Browse files
committed
[CS] Add a fallback for overload locators that failed to simplify
If an overload locator couldn't be simplified to its anchor, fallback to the anchor of the locator instead. Also add an assert so that we can track down whether this is actually valid or not. Resolves rdar://89097800.
1 parent 616a404 commit c05abfe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4483,6 +4483,15 @@ bool ConstraintSystem::diagnoseAmbiguity(ArrayRef<Solution> solutions) {
44834483
// is not sufficiently centralized in the AST.
44844484
DeclNameRef name(getOverloadChoiceName(overload.choices));
44854485
auto anchor = simplifyLocatorToAnchor(overload.locator);
4486+
if (!anchor) {
4487+
// It's not clear that this is actually valid. Just use the overload's
4488+
// anchor for release builds, but assert so we can properly diagnose
4489+
// this case if it happens to be hit. Note that the overload will
4490+
// *always* be anchored, otherwise everything would be broken, ie. this
4491+
// assertion would be the least of our worries.
4492+
anchor = overload.locator->getAnchor();
4493+
assert(false && "locator could not be simplified to anchor");
4494+
}
44864495

44874496
// Emit the ambiguity diagnostic.
44884497
auto &DE = getASTContext().Diags;

0 commit comments

Comments
 (0)