Skip to content

Commit eeb23ad

Browse files
committed
Addressing CR feedback
1 parent 4186167 commit eeb23ad

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

src/compiler/checker.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ module ts {
127127

128128
let resolutionTargets: Object[] = [];
129129
let resolutionResults: boolean[] = [];
130-
let resolutionCount = 0;
131130

132131
let mergedSymbols: Symbol[] = [];
133132
let symbolLinks: SymbolLinks[] = [];
@@ -2020,29 +2019,33 @@ module ts {
20202019
// Push an entry on the type resolution stack. If an entry with the given target is not already on the stack,
20212020
// a new entry with that target and an associated result value of true is pushed on the stack, and the value
20222021
// true is returned. Otherwise, a circularity has occurred and the result values of the existing entry and
2023-
// all entries pushed after it are changed to false, and the value false is returned. The target object has
2024-
// no significance other than to provide a unique identity for a particular type resolution result.
2022+
// all entries pushed after it are changed to false, and the value false is returned. The target object provides
2023+
// a unique identity for a particular type resolution result: Symbol instances are used to track resolution of
2024+
// SymbolLinks.type, SymbolLinks instances are used to track resolution of SymbolLinks.declaredType, and
2025+
// Signature instances are used to track resolution of Signature.resolvedReturnType.
20252026
function pushTypeResolution(target: Object): boolean {
2026-
for (let i = 0; i < resolutionCount; i++) {
2027-
if (resolutionTargets[i] === target) {
2028-
do {
2029-
resolutionResults[i++] = false;
2030-
}
2031-
while (i < resolutionCount);
2032-
return false;
2027+
let i = 0;
2028+
let count = resolutionTargets.length;
2029+
while (i < count && resolutionTargets[i] !== target) {
2030+
i++;
2031+
}
2032+
if (i < count) {
2033+
do {
2034+
resolutionResults[i++] = false;
20332035
}
2036+
while (i < count);
2037+
return false;
20342038
}
2035-
resolutionTargets[resolutionCount] = target;
2036-
resolutionResults[resolutionCount] = true;
2037-
resolutionCount++;
2039+
resolutionTargets.push(target);
2040+
resolutionResults.push(true);
20382041
return true;
20392042
}
20402043

20412044
// Pop an entry from the type resolution stack and return its associated result value. The result value will
20422045
// be true if no circularities were detected, or false if a circularity was found.
20432046
function popTypeResolution(): boolean {
2044-
resolutionTargets[--resolutionCount] = undefined;
2045-
return resolutionResults[resolutionCount];
2047+
resolutionTargets.pop();
2048+
return resolutionResults.pop();
20462049
}
20472050

20482051
function getRootDeclaration(node: Node): Node {

0 commit comments

Comments
 (0)