Skip to content

Commit c65d9f2

Browse files
committed
Initial attempt. Totally doesn't work.
1 parent 1793813 commit c65d9f2

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/compiler/checker.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21439,7 +21439,7 @@ namespace ts {
2143921439
// function foo(): void;
2144021440
// foo<number>(0);
2144121441
//
21442-
let candidateForArgumentError: Signature | undefined;
21442+
let candidatesForArgumentError: Signature[] | undefined;
2144321443
let candidateForArgumentArityError: Signature | undefined;
2144421444
let candidateForTypeArgumentError: Signature | undefined;
2144521445
let result: Signature | undefined;
@@ -21474,8 +21474,13 @@ namespace ts {
2147421474
// If candidate is undefined, it means that no candidates had a suitable arity. In that case,
2147521475
// skip the checkApplicableSignature check.
2147621476
if (reportErrors) {
21477-
if (candidateForArgumentError) {
21478-
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, CheckMode.Normal, /*reportErrors*/ true);
21477+
if (candidatesForArgumentError) {
21478+
createDiagnosticForNodeFromMessageChain // is what I really want to call
21479+
chainDiagnosticMessages(chain, Diagnostics.Failed_to_find_a_suitable_overload_for_this_call);
21480+
diagnostics.add(createDiagnosticForNode(node, Diagnostics.Failed_to_find_a_suitable_overload_for_this_call));
21481+
for (const c of candidatesForArgumentError) {
21482+
checkApplicableSignature(node, args, c, assignableRelation, CheckMode.Normal, /*reportErrors*/ true);
21483+
}
2147921484
}
2148021485
else if (candidateForArgumentArityError) {
2148121486
diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
@@ -21500,7 +21505,7 @@ namespace ts {
2150021505
return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
2150121506

2150221507
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>, signatureHelpTrailingComma = false) {
21503-
candidateForArgumentError = undefined;
21508+
candidatesForArgumentError = undefined;
2150421509
candidateForArgumentArityError = undefined;
2150521510
candidateForTypeArgumentError = undefined;
2150621511

@@ -21510,7 +21515,7 @@ namespace ts {
2151021515
return undefined;
2151121516
}
2151221517
if (!checkApplicableSignature(node, args, candidate, relation, CheckMode.Normal, /*reportErrors*/ false)) {
21513-
candidateForArgumentError = candidate;
21518+
candidatesForArgumentError = [candidate];
2151421519
return undefined;
2151521520
}
2151621521
return candidate;
@@ -21552,8 +21557,8 @@ namespace ts {
2155221557
}
2155321558
if (!checkApplicableSignature(node, args, checkCandidate, relation, argCheckMode, /*reportErrors*/ false)) {
2155421559
// Give preference to error candidates that have no rest parameters (as they are more specific)
21555-
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
21556-
candidateForArgumentError = checkCandidate;
21560+
if (getMinArgumentCount(checkCandidate) <= args.length && args.length <= getParameterCount(checkCandidate)) {
21561+
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
2155721562
}
2155821563
continue;
2155921564
}
@@ -21574,8 +21579,8 @@ namespace ts {
2157421579
}
2157521580
if (!checkApplicableSignature(node, args, checkCandidate, relation, argCheckMode, /*reportErrors*/ false)) {
2157621581
// Give preference to error candidates that have no rest parameters (as they are more specific)
21577-
if (!candidateForArgumentError || getEffectiveRestType(candidateForArgumentError) || !getEffectiveRestType(checkCandidate)) {
21578-
candidateForArgumentError = checkCandidate;
21582+
if (getMinArgumentCount(checkCandidate) <= args.length && args.length <= getParameterCount(checkCandidate)) {
21583+
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
2157921584
}
2158021585
continue;
2158121586
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,10 @@
26212621
"category": "Error",
26222622
"code": 2754
26232623
},
2624+
"Failed to find a suitable overload for this call.": {
2625+
"category": "Error",
2626+
"code": 2755
2627+
},
26242628

26252629
"Import declaration '{0}' is using private name '{1}'.": {
26262630
"category": "Error",

0 commit comments

Comments
 (0)