@@ -127,7 +127,6 @@ module ts {
127
127
128
128
let resolutionTargets: Object[] = [];
129
129
let resolutionResults: boolean[] = [];
130
- let resolutionCount = 0;
131
130
132
131
let mergedSymbols: Symbol[] = [];
133
132
let symbolLinks: SymbolLinks[] = [];
@@ -2020,29 +2019,33 @@ module ts {
2020
2019
// Push an entry on the type resolution stack. If an entry with the given target is not already on the stack,
2021
2020
// a new entry with that target and an associated result value of true is pushed on the stack, and the value
2022
2021
// 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.
2025
2026
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;
2033
2035
}
2036
+ while (i < count);
2037
+ return false;
2034
2038
}
2035
- resolutionTargets[resolutionCount] = target;
2036
- resolutionResults[resolutionCount] = true;
2037
- resolutionCount++;
2039
+ resolutionTargets.push(target);
2040
+ resolutionResults.push(true);
2038
2041
return true;
2039
2042
}
2040
2043
2041
2044
// Pop an entry from the type resolution stack and return its associated result value. The result value will
2042
2045
// be true if no circularities were detected, or false if a circularity was found.
2043
2046
function popTypeResolution(): boolean {
2044
- resolutionTargets[--resolutionCount] = undefined ;
2045
- return resolutionResults[resolutionCount] ;
2047
+ resolutionTargets.pop() ;
2048
+ return resolutionResults.pop() ;
2046
2049
}
2047
2050
2048
2051
function getRootDeclaration(node: Node): Node {
0 commit comments