@@ -9204,25 +9204,39 @@ namespace ts {
9204
9204
let result = Ternary.True;
9205
9205
const saveErrorInfo = errorInfo;
9206
9206
9207
- outer: for (const t of targetSignatures) {
9208
- // Only elaborate errors from the first failure
9209
- let shouldElaborateErrors = reportErrors;
9210
- for (const s of sourceSignatures) {
9211
- const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9212
- if (related) {
9213
- result &= related;
9214
- errorInfo = saveErrorInfo;
9215
- continue outer;
9207
+ if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) {
9208
+ // We instantiations of the same anonymous type (which typically will be the type of a method).
9209
+ // Simply do a pairwise comparison of the signatures in the two signature lists instead of the
9210
+ // much more expensive N * M comparison matrix we explore below.
9211
+ for (let i = 0; i < targetSignatures.length; i++) {
9212
+ const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors);
9213
+ if (!related) {
9214
+ return Ternary.False;
9216
9215
}
9217
- shouldElaborateErrors = false ;
9216
+ result &= related ;
9218
9217
}
9218
+ }
9219
+ else {
9220
+ outer: for (const t of targetSignatures) {
9221
+ // Only elaborate errors from the first failure
9222
+ let shouldElaborateErrors = reportErrors;
9223
+ for (const s of sourceSignatures) {
9224
+ const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9225
+ if (related) {
9226
+ result &= related;
9227
+ errorInfo = saveErrorInfo;
9228
+ continue outer;
9229
+ }
9230
+ shouldElaborateErrors = false;
9231
+ }
9219
9232
9220
- if (shouldElaborateErrors) {
9221
- reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9222
- typeToString(source),
9223
- signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9233
+ if (shouldElaborateErrors) {
9234
+ reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9235
+ typeToString(source),
9236
+ signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9237
+ }
9238
+ return Ternary.False;
9224
9239
}
9225
- return Ternary.False;
9226
9240
}
9227
9241
return result;
9228
9242
}
0 commit comments