@@ -192,15 +192,14 @@ namespace ts {
192192 ForStatement = 1 << 10 , // Enclosing block-scoped container is a ForStatement
193193 ForInOrForOfStatement = 1 << 11 , // Enclosing block-scoped container is a ForInStatement or ForOfStatement
194194 ConstructorWithCapturedSuper = 1 << 12 , // Enclosed in a constructor that captures 'this' for use with 'super'
195- ComputedPropertyName = 1 << 13 , // Enclosed in a computed property name
196195 // NOTE: do not add more ancestor flags without also updating AncestorFactsMask below.
197196 // NOTE: when adding a new ancestor flag, be sure to update the subtree flags below.
198197
199198 //
200199 // Ancestor masks
201200 //
202201
203- AncestorFactsMask = ( ComputedPropertyName << 1 ) - 1 ,
202+ AncestorFactsMask = ( ConstructorWithCapturedSuper << 1 ) - 1 ,
204203
205204 // We are always in *some* kind of block scope, but only specific block-scope containers are
206205 // top-level or Blocks.
@@ -213,14 +212,14 @@ namespace ts {
213212
214213 // Functions, methods, and accessors are both new lexical scopes and new block scopes.
215214 FunctionIncludes = Function | TopLevel ,
216- FunctionExcludes = BlockScopeExcludes & ~ TopLevel | ArrowFunction | AsyncFunctionBody | CapturesThis | NonStaticClassElement | ConstructorWithCapturedSuper | ComputedPropertyName ,
215+ FunctionExcludes = BlockScopeExcludes & ~ TopLevel | ArrowFunction | AsyncFunctionBody | CapturesThis | NonStaticClassElement | ConstructorWithCapturedSuper ,
217216
218217 AsyncFunctionBodyIncludes = FunctionIncludes | AsyncFunctionBody ,
219218 AsyncFunctionBodyExcludes = FunctionExcludes & ~ NonStaticClassElement ,
220219
221220 // Arrow functions are lexically scoped to their container, but are new block scopes.
222221 ArrowFunctionIncludes = ArrowFunction | TopLevel ,
223- ArrowFunctionExcludes = BlockScopeExcludes & ~ TopLevel | ConstructorWithCapturedSuper | ComputedPropertyName ,
222+ ArrowFunctionExcludes = BlockScopeExcludes & ~ TopLevel | ConstructorWithCapturedSuper ,
224223
225224 // Constructors are both new lexical scopes and new block scopes. Constructors are also
226225 // always considered non-static members of a class.
@@ -249,25 +248,23 @@ namespace ts {
249248 IterationStatementBlockIncludes = IterationStatementBlock ,
250249 IterationStatementBlockExcludes = BlockScopeExcludes ,
251250
252- // Computed property names track subtree flags differently than their containing members.
253- ComputedPropertyNameIncludes = ComputedPropertyName ,
254- ComputedPropertyNameExcludes = None ,
255-
256251 //
257252 // Subtree facts
258253 //
259- NewTarget = 1 << 14 , // Contains a 'new.target' meta-property
260- NewTargetInComputedPropertyName = 1 << 15 , // Contains a 'new.target' meta-property in a computed property name.
261254
262- LexicalThis = 1 << 16 , // Contains a lexical `this` reference.
263- LexicalThisInComputedPropertyName = 1 << 17 , // Contains a lexical `this` reference in a computed property name.
255+ NewTarget = 1 << 13 , // Contains a 'new.target' meta-property
256+ LexicalThis = 1 << 14 , // Contains a lexical `this` reference.
257+ CapturedLexicalThis = 1 << 15 , // Contains a lexical `this` reference captured by an arrow function.
264258
265259 //
266260 // Subtree masks
267261 //
268262
269263 SubtreeFactsMask = ~ AncestorFactsMask ,
270- PropagateNewTargetMask = NewTarget | NewTargetInComputedPropertyName ,
264+
265+ PropagateNewTargetMask = NewTarget ,
266+ ArrowFunctionSubtreeExcludes = None ,
267+ FunctionSubtreeExcludes = NewTarget | LexicalThis | CapturedLexicalThis ,
271268 }
272269
273270 export function transformES2015 ( context : TransformationContext ) {
@@ -599,12 +596,7 @@ namespace ts {
599596 }
600597
601598 function visitThisKeyword ( node : Node ) : Node {
602- if ( hierarchyFacts & HierarchyFacts . ComputedPropertyName ) {
603- hierarchyFacts |= HierarchyFacts . LexicalThisInComputedPropertyName ;
604- }
605- else {
606- hierarchyFacts |= HierarchyFacts . LexicalThis ;
607- }
599+ hierarchyFacts |= HierarchyFacts . LexicalThis ;
608600 if ( convertedLoopState ) {
609601 if ( hierarchyFacts & HierarchyFacts . ArrowFunction ) {
610602 // if the enclosing function is an ArrowFunction then we use the captured 'this' keyword.
@@ -913,7 +905,7 @@ namespace ts {
913905 }
914906
915907 statements . push ( constructorFunction ) ;
916- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , HierarchyFacts . None ) ;
908+ exitSubtree ( ancestorFacts , HierarchyFacts . FunctionSubtreeExcludes , HierarchyFacts . None ) ;
917909 convertedLoopState = savedConvertedLoopState ;
918910 }
919911
@@ -1621,7 +1613,6 @@ namespace ts {
16211613 * @param member The MethodDeclaration node.
16221614 */
16231615 function transformClassMethodDeclarationToStatement ( receiver : LeftHandSideExpression , member : MethodDeclaration , container : Node ) {
1624- const ancestorFacts = enterSubtree ( HierarchyFacts . None , HierarchyFacts . None ) ;
16251616 const commentRange = getCommentRange ( member ) ;
16261617 const sourceMapRange = getSourceMapRange ( member ) ;
16271618 const memberName = createMemberAccessForPropertyName ( receiver , visitNode ( member . name , visitor , isPropertyName ) , /*location*/ member . name ) ;
@@ -1643,8 +1634,6 @@ namespace ts {
16431634 // No source map should be emitted for this statement to align with the
16441635 // old emitter.
16451636 setEmitFlags ( statement , EmitFlags . NoSourceMap ) ;
1646-
1647- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , hierarchyFacts & HierarchyFacts . PropagateNewTargetMask ? HierarchyFacts . NewTarget : HierarchyFacts . None ) ;
16481637 return statement ;
16491638 }
16501639
@@ -1671,8 +1660,6 @@ namespace ts {
16711660 * @param receiver The receiver for the member.
16721661 */
16731662 function transformAccessorsToExpression ( receiver : LeftHandSideExpression , { firstAccessor, getAccessor, setAccessor } : AllAccessorDeclarations , container : Node , startsOnNewLine : boolean ) : Expression {
1674- const ancestorFacts = enterSubtree ( HierarchyFacts . None , HierarchyFacts . None ) ;
1675-
16761663 // To align with source maps in the old emitter, the receiver and property name
16771664 // arguments are both mapped contiguously to the accessor name.
16781665 const target = getMutableClone ( receiver ) ;
@@ -1720,7 +1707,6 @@ namespace ts {
17201707 startOnNewLine ( call ) ;
17211708 }
17221709
1723- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , hierarchyFacts & HierarchyFacts . PropagateNewTargetMask ? HierarchyFacts . NewTarget : HierarchyFacts . None ) ;
17241710 return call ;
17251711 }
17261712
@@ -1779,7 +1765,7 @@ namespace ts {
17791765 ? getLocalName ( node )
17801766 : node . name ;
17811767
1782- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , HierarchyFacts . None ) ;
1768+ exitSubtree ( ancestorFacts , HierarchyFacts . FunctionSubtreeExcludes , HierarchyFacts . None ) ;
17831769 convertedLoopState = savedConvertedLoopState ;
17841770 return updateFunctionExpression (
17851771 node ,
@@ -1812,7 +1798,7 @@ namespace ts {
18121798 ? getLocalName ( node )
18131799 : node . name ;
18141800
1815- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , HierarchyFacts . None ) ;
1801+ exitSubtree ( ancestorFacts , HierarchyFacts . FunctionSubtreeExcludes , HierarchyFacts . None ) ;
18161802 convertedLoopState = savedConvertedLoopState ;
18171803 return updateFunctionDeclaration (
18181804 node ,
@@ -1846,7 +1832,7 @@ namespace ts {
18461832 name = getGeneratedNameForNode ( node ) ;
18471833 }
18481834
1849- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , HierarchyFacts . None ) ;
1835+ exitSubtree ( ancestorFacts , HierarchyFacts . FunctionSubtreeExcludes , HierarchyFacts . None ) ;
18501836 convertedLoopState = savedConvertedLoopState ;
18511837 return setOriginalNode (
18521838 setTextRange (
@@ -3443,7 +3429,6 @@ namespace ts {
34433429 * @param receiver The receiver for the assignment.
34443430 */
34453431 function transformObjectLiteralMethodDeclarationToExpression ( method : MethodDeclaration , receiver : Expression , container : Node , startsOnNewLine : boolean ) {
3446- const ancestorFacts = enterSubtree ( HierarchyFacts . None , HierarchyFacts . None ) ;
34473432 const expression = createAssignment (
34483433 createMemberAccessForPropertyName (
34493434 receiver ,
@@ -3455,7 +3440,6 @@ namespace ts {
34553440 if ( startsOnNewLine ) {
34563441 startOnNewLine ( expression ) ;
34573442 }
3458- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , hierarchyFacts & HierarchyFacts . PropagateNewTargetMask ? HierarchyFacts . NewTarget : HierarchyFacts . None ) ;
34593443 return expression ;
34603444 }
34613445
@@ -3535,7 +3519,7 @@ namespace ts {
35353519 else {
35363520 updated = updateSetAccessor ( node , node . decorators , node . modifiers , node . name , parameters , body ) ;
35373521 }
3538- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , HierarchyFacts . None ) ;
3522+ exitSubtree ( ancestorFacts , HierarchyFacts . FunctionSubtreeExcludes , HierarchyFacts . None ) ;
35393523 convertedLoopState = savedConvertedLoopState ;
35403524 return updated ;
35413525 }
@@ -3556,10 +3540,7 @@ namespace ts {
35563540 }
35573541
35583542 function visitComputedPropertyName ( node : ComputedPropertyName ) {
3559- const ancestorFacts = enterSubtree ( HierarchyFacts . ComputedPropertyNameExcludes , HierarchyFacts . ComputedPropertyNameIncludes ) ;
3560- const updated = visitEachChild ( node , visitor , context ) ;
3561- exitSubtree ( ancestorFacts , HierarchyFacts . PropagateNewTargetMask , hierarchyFacts & HierarchyFacts . PropagateNewTargetMask ? HierarchyFacts . NewTargetInComputedPropertyName : HierarchyFacts . None ) ;
3562- return updated ;
3543+ return visitEachChild ( node , visitor , context ) ;
35633544 }
35643545
35653546 /**
@@ -4152,12 +4133,7 @@ namespace ts {
41524133
41534134 function visitMetaProperty ( node : MetaProperty ) {
41544135 if ( node . keywordToken === SyntaxKind . NewKeyword && node . name . escapedText === "target" ) {
4155- if ( hierarchyFacts & HierarchyFacts . ComputedPropertyName ) {
4156- hierarchyFacts |= HierarchyFacts . NewTargetInComputedPropertyName ;
4157- }
4158- else {
4159- hierarchyFacts |= HierarchyFacts . NewTarget ;
4160- }
4136+ hierarchyFacts |= HierarchyFacts . NewTarget ;
41614137 return createFileLevelUniqueName ( "_newTarget" ) ;
41624138 }
41634139 return node ;
0 commit comments