From f59229bf22098462cae5bb94778f0a47b4aaedff Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 26 Sep 2018 06:54:37 -0700 Subject: [PATCH] Only add unique inferences to candidate arrays --- src/compiler/checker.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f3201ecf8af..ef367e86405 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1,6 +1,3 @@ - - - /* @internal */ namespace ts { const ambientModuleSymbolRegex = /^".+"$/; @@ -13553,10 +13550,10 @@ namespace ts { // We make contravariant inferences only if we are in a pure contravariant position, // i.e. only if we have not descended into a bivariant position. if (contravariant && !bivariant) { - inference.contraCandidates = append(inference.contraCandidates, candidate); + inference.contraCandidates = appendIfUnique(inference.contraCandidates, candidate); } else { - inference.candidates = append(inference.candidates, candidate); + inference.candidates = appendIfUnique(inference.candidates, candidate); } } if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && !isTypeParameterAtTopLevel(originalTarget, target)) {