(signatures, result, callChainFlags)
| 75280 | // const b: B; |
| 75281 | // b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void] |
| 75282 | function reorderCandidates(signatures, result, callChainFlags) { |
| 75283 | var lastParent; |
| 75284 | var lastSymbol; |
| 75285 | var cutoffIndex = 0; |
| 75286 | var index; |
| 75287 | var specializedIndex = -1; |
| 75288 | var spliceIndex; |
| 75289 | ts.Debug.assert(!result.length); |
| 75290 | for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) { |
| 75291 | var signature = signatures_7[_i]; |
| 75292 | var symbol = signature.declaration && getSymbolOfNode(signature.declaration); |
| 75293 | var parent = signature.declaration && signature.declaration.parent; |
| 75294 | if (!lastSymbol || symbol === lastSymbol) { |
| 75295 | if (lastParent && parent === lastParent) { |
| 75296 | index = index + 1; |
| 75297 | } |
| 75298 | else { |
| 75299 | lastParent = parent; |
| 75300 | index = cutoffIndex; |
| 75301 | } |
| 75302 | } |
| 75303 | else { |
| 75304 | // current declaration belongs to a different symbol |
| 75305 | // set cutoffIndex so re-orderings in the future won't change result set from 0 to cutoffIndex |
| 75306 | index = cutoffIndex = result.length; |
| 75307 | lastParent = parent; |
| 75308 | } |
| 75309 | lastSymbol = symbol; |
| 75310 | // specialized signatures always need to be placed before non-specialized signatures regardless |
| 75311 | // of the cutoff position; see GH#1133 |
| 75312 | if (signatureHasLiteralTypes(signature)) { |
| 75313 | specializedIndex++; |
| 75314 | spliceIndex = specializedIndex; |
| 75315 | // The cutoff index always needs to be greater than or equal to the specialized signature index |
| 75316 | // in order to prevent non-specialized signatures from being added before a specialized |
| 75317 | // signature. |
| 75318 | cutoffIndex++; |
| 75319 | } |
| 75320 | else { |
| 75321 | spliceIndex = index; |
| 75322 | } |
| 75323 | result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature); |
| 75324 | } |
| 75325 | } |
| 75326 | function isSpreadArgument(arg) { |
| 75327 | return !!arg && (arg.kind === 225 /* SyntaxKind.SpreadElement */ || arg.kind === 232 /* SyntaxKind.SyntheticExpression */ && arg.isSpread); |
| 75328 | } |
no test coverage detected