Skip to content

Commit c300edb

Browse files
committed
[ConstraintSystem] Pass decl to diagnostic instead of trying to validate loc
`DiagnosticEngine` does the checking for declaration, so all we need to do for ambiguity diagnostic is to use an overload declaration.
1 parent 399d349 commit c300edb

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4270,22 +4270,18 @@ static bool diagnoseAmbiguityWithContextualType(
42704270
for (const auto &solution : solutions) {
42714271
auto overload = solution.getOverloadChoice(calleeLocator);
42724272
if (auto *decl = overload.choice.getDeclOrNull()) {
4273-
auto loc = decl->getLoc();
4274-
if (loc.isInvalid())
4275-
continue;
4276-
42774273
auto type = solution.simplifyType(overload.boundType);
42784274

42794275
if (isExpr<ApplyExpr>(anchor) || isExpr<SubscriptExpr>(anchor)) {
42804276
auto fnType = type->castTo<FunctionType>();
42814277
DE.diagnose(
4282-
loc,
4278+
decl,
42834279
contextualTy->is<ProtocolType>()
42844280
? diag::overload_result_type_does_not_conform
42854281
: diag::cannot_convert_candidate_result_to_contextual_type,
42864282
decl->getName(), fnType->getResult(), contextualTy);
42874283
} else {
4288-
DE.diagnose(loc, diag::found_candidate_type, type);
4284+
DE.diagnose(decl, diag::found_candidate_type, type);
42894285
}
42904286
}
42914287
}

0 commit comments

Comments
 (0)