@@ -6110,49 +6110,47 @@ module ts {
61106110 var result = candidates;
61116111 var lastParent: Node;
61126112 var lastSymbol: Symbol;
6113- var cutoffPos : number = 0;
6114- var pos : number;
6115- var specializedPos : number = -1;
6116- var splicePos : number;
6113+ var cutoffIndex : number = 0;
6114+ var index : number;
6115+ var specializedIndex : number = -1;
6116+ var spliceIndex : number;
61176117 Debug.assert(!result.length);
61186118 for (var i = 0; i < signatures.length; i++) {
61196119 var signature = signatures[i];
61206120 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
61216121 var parent = signature.declaration && signature.declaration.parent;
61226122 if (!lastSymbol || symbol === lastSymbol) {
61236123 if (lastParent && parent === lastParent) {
6124- pos ++;
6124+ index ++;
61256125 }
61266126 else {
61276127 lastParent = parent;
6128- pos = cutoffPos ;
6128+ index = cutoffIndex ;
61296129 }
61306130 }
61316131 else {
61326132 // current declaration belongs to a different symbol
6133- // set cutoffPos so re-orderings in the future won't change result set from 0 to cutoffPos
6134- pos = cutoffPos = result.length;
6133+ // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex
6134+ index = cutoffIndex = result.length;
61356135 lastParent = parent;
61366136 }
61376137 lastSymbol = symbol;
61386138
61396139 // specialized signatures always need to be placed before non-specialized signatures regardless
61406140 // of the cutoff position; see GH#1133
61416141 if (signature.hasStringLiterals) {
6142- splicePos = ++specializedPos;
6143- // The cutoff position needs to be increased to account for the fact that we are adding things
6144- // before the cutoff point. If the cutoff position is not incremented, merged interfaces will
6145- // start adding their merged signatures at the wrong position
6146- ++cutoffPos;
6142+ specializedIndex++;
6143+ spliceIndex = specializedIndex;
6144+ // The cutoff index always needs to be greater than or equal to the specialized signature index
6145+ // in order to prevent non-specialized signatures from being added before a specialized
6146+ // signature.
6147+ cutoffIndex++;
61476148 }
61486149 else {
6149- splicePos = pos ;
6150+ spliceIndex = index ;
61506151 }
61516152
6152- for (var j = result.length; j > splicePos; j--) {
6153- result[j] = result[j - 1];
6154- }
6155- result[splicePos] = signature;
6153+ result.splice(spliceIndex, 0, signature);
61566154 }
61576155 }
61586156 }
0 commit comments