Add a flag so we don't repeatedly finding super call

This commit is contained in:
Kanchalai Tanglertsampan
2016-02-03 14:47:39 -08:00
parent 2dbc998da4
commit aff6775a36
2 changed files with 5 additions and 2 deletions

View File

@@ -7284,8 +7284,11 @@ namespace ts {
*/
function getSuperCallInConstructor(constructor: ConstructorDeclaration): ExpressionStatement {
const links = getNodeLinks(constructor);
if (!links.superCall) {
// Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result
if (links.hasSuperCall === undefined) {
links.superCall = <ExpressionStatement>findFirstSuperCall(constructor.body);
links.hasSuperCall = links.superCall ? true : false;
}
return links.superCall;
}

View File

@@ -459,7 +459,6 @@ namespace ts {
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement,
}
/* @internal */
export const enum RelationComparisonResult {
Succeeded = 1, // Should be truthy
@@ -2088,6 +2087,7 @@ namespace ts {
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element
hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt.
superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing
}