[AST] Remove ArgumentList::composeTupleOrParenType

Remove a redundant bit of diagnostic logic now
that we better diagnose cases where an uncallable
variable is in an overload set for a mismatched
apply. Tweak another bit of diagnostic logic to
only apply to a single arg/param case, as that
seems to be what it's meant for.
This commit is contained in:
Hamish Knight
2022-07-26 12:51:54 +01:00
parent 4915513387
commit 5418e8d934
5 changed files with 6 additions and 59 deletions

View File

@@ -4403,19 +4403,17 @@ static bool diagnoseAmbiguity(
type->lookThroughAllOptionalTypes()->getAs<AnyFunctionType>();
assert(fn);
if (fn->getNumParams() == 1) {
auto *argList =
solution.getArgumentList(solution.Fixes.front()->getLocator());
assert(argList);
auto *argList =
solution.getArgumentList(solution.Fixes.front()->getLocator());
assert(argList);
if (fn->getNumParams() == 1 && argList->isUnary()) {
const auto &param = fn->getParams()[0];
auto argType = argList->composeTupleOrParenType(
cs.getASTContext(),
[&](Expr *E) { return solution.getResolvedType(E); });
auto argTy = solution.getResolvedType(argList->getUnaryExpr());
DE.diagnose(noteLoc, diag::candidate_has_invalid_argument_at_position,
solution.simplifyType(param.getPlainType()),
/*position=*/1, param.isInOut(), argType);
/*position=*/1, param.isInOut(), argTy);
} else {
DE.diagnose(noteLoc, diag::candidate_partial_match,
fn->getParamListAsString(fn->getParams()));