@@ -9228,25 +9228,39 @@ namespace ts {
9228
9228
let result = Ternary.True;
9229
9229
const saveErrorInfo = errorInfo;
9230
9230
9231
- outer: for (const t of targetSignatures) {
9232
- // Only elaborate errors from the first failure
9233
- let shouldElaborateErrors = reportErrors;
9234
- for (const s of sourceSignatures) {
9235
- const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9236
- if (related) {
9237
- result &= related;
9238
- errorInfo = saveErrorInfo;
9239
- continue outer;
9231
+ if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) {
9232
+ // We instantiations of the same anonymous type (which typically will be the type of a method).
9233
+ // Simply do a pairwise comparison of the signatures in the two signature lists instead of the
9234
+ // much more expensive N * M comparison matrix we explore below.
9235
+ for (let i = 0; i < targetSignatures.length; i++) {
9236
+ const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors);
9237
+ if (!related) {
9238
+ return Ternary.False;
9240
9239
}
9241
- shouldElaborateErrors = false ;
9240
+ result &= related ;
9242
9241
}
9242
+ }
9243
+ else {
9244
+ outer: for (const t of targetSignatures) {
9245
+ // Only elaborate errors from the first failure
9246
+ let shouldElaborateErrors = reportErrors;
9247
+ for (const s of sourceSignatures) {
9248
+ const related = signatureRelatedTo(s, t, shouldElaborateErrors);
9249
+ if (related) {
9250
+ result &= related;
9251
+ errorInfo = saveErrorInfo;
9252
+ continue outer;
9253
+ }
9254
+ shouldElaborateErrors = false;
9255
+ }
9243
9256
9244
- if (shouldElaborateErrors) {
9245
- reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9246
- typeToString(source),
9247
- signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9257
+ if (shouldElaborateErrors) {
9258
+ reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1,
9259
+ typeToString(source),
9260
+ signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind));
9261
+ }
9262
+ return Ternary.False;
9248
9263
}
9249
- return Ternary.False;
9250
9264
}
9251
9265
return result;
9252
9266
}
0 commit comments