Skip to content

Commit 01b539e

Browse files
authored
Merge pull request swiftlang#41461 from bnbarham/overload-anchor-fallback
[CS] Add a fallback for overload locators that failed to simplify
2 parents 3fe6782 + c05abfe commit 01b539e

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
@@ -4526,6 +4526,15 @@ bool ConstraintSystem::diagnoseAmbiguity(ArrayRef<Solution> solutions) {
45264526
// is not sufficiently centralized in the AST.
45274527
DeclNameRef name(getOverloadChoiceName(overload.choices));
45284528
auto anchor = simplifyLocatorToAnchor(overload.locator);
4529+
if (!anchor) {
4530+
// It's not clear that this is actually valid. Just use the overload's
4531+
// anchor for release builds, but assert so we can properly diagnose
4532+
// this case if it happens to be hit. Note that the overload will
4533+
// *always* be anchored, otherwise everything would be broken, ie. this
4534+
// assertion would be the least of our worries.
4535+
anchor = overload.locator->getAnchor();
4536+
assert(false && "locator could not be simplified to anchor");
4537+
}
45294538

45304539
// Emit the ambiguity diagnostic.
45314540
auto &DE = getASTContext().Diags;

0 commit comments

Comments
 (0)