Skip to content

Commit aff6775

Browse files
author
Kanchalai Tanglertsampan
committed
Add a flag so we don't repeatedly finding super call
1 parent 2dbc998 commit aff6775

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/compiler/checker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7284,8 +7284,11 @@ namespace ts {
72847284
*/
72857285
function getSuperCallInConstructor(constructor: ConstructorDeclaration): ExpressionStatement {
72867286
const links = getNodeLinks(constructor);
7287-
if (!links.superCall) {
7287+
7288+
// Only trying to find super-call if we haven't yet tried to find one. Once we try, we will record the result
7289+
if (links.hasSuperCall === undefined) {
72887290
links.superCall = <ExpressionStatement>findFirstSuperCall(constructor.body);
7291+
links.hasSuperCall = links.superCall ? true : false;
72897292
}
72907293
return links.superCall;
72917294
}

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ namespace ts {
459459
IntrinsicElement = IntrinsicNamedElement | IntrinsicIndexedElement,
460460
}
461461

462-
463462
/* @internal */
464463
export const enum RelationComparisonResult {
465464
Succeeded = 1, // Should be truthy
@@ -2088,6 +2087,7 @@ namespace ts {
20882087
importOnRightSide?: Symbol; // for import declarations - import that appear on the right side
20892088
jsxFlags?: JsxFlags; // flags for knowning what kind of element/attributes we're dealing with
20902089
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element
2090+
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.
20912091
superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing
20922092
}
20932093

0 commit comments

Comments
 (0)