@@ -10,6 +10,7 @@ namespace ts {
1010 /** Enables substitutions for block-scoped bindings. */
1111 BlockScopedBindings = 1 << 1 ,
1212 }
13+
1314 /**
1415 * If loop contains block scoped binding captured in some function then loop body is converted to a function.
1516 * Lexical bindings declared in loop initializer will be passed into the loop body function as parameters,
@@ -166,6 +167,9 @@ namespace ts {
166167 let enclosingBlockScopeContainerParent : Node ;
167168 let containingNonArrowFunction : FunctionLikeDeclaration | ClassElement ;
168169
170+ /** Tracks the container that determines whether `super.x` is a static. */
171+ let superScopeContainer : FunctionLikeDeclaration | ClassElement ;
172+
169173 /**
170174 * Used to track if we are emitting body of the converted loop
171175 */
@@ -203,6 +207,7 @@ namespace ts {
203207
204208 function saveStateAndInvoke < T > ( node : Node , f : ( node : Node ) => T ) : T {
205209 const savedContainingNonArrowFunction = containingNonArrowFunction ;
210+ const savedSuperScopeContainer = superScopeContainer ;
206211 const savedCurrentParent = currentParent ;
207212 const savedCurrentNode = currentNode ;
208213 const savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer ;
@@ -219,6 +224,7 @@ namespace ts {
219224
220225 convertedLoopState = savedConvertedLoopState ;
221226 containingNonArrowFunction = savedContainingNonArrowFunction ;
227+ superScopeContainer = savedSuperScopeContainer ;
222228 currentParent = savedCurrentParent ;
223229 currentNode = savedCurrentNode ;
224230 enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer ;
@@ -414,13 +420,16 @@ namespace ts {
414420 }
415421
416422 switch ( currentParent . kind ) {
423+ case SyntaxKind . FunctionExpression :
417424 case SyntaxKind . Constructor :
418425 case SyntaxKind . MethodDeclaration :
419426 case SyntaxKind . GetAccessor :
420427 case SyntaxKind . SetAccessor :
421428 case SyntaxKind . FunctionDeclaration :
422- case SyntaxKind . FunctionExpression :
423429 containingNonArrowFunction = < FunctionLikeDeclaration > currentParent ;
430+ if ( ! ( containingNonArrowFunction . emitFlags & NodeEmitFlags . AsyncFunctionBody ) ) {
431+ superScopeContainer = containingNonArrowFunction ;
432+ }
424433 break ;
425434 }
426435 }
@@ -2820,9 +2829,9 @@ namespace ts {
28202829 * Visits the `super` keyword
28212830 */
28222831 function visitSuperKeyword ( node : PrimaryExpression ) : LeftHandSideExpression {
2823- return containingNonArrowFunction
2824- && isClassElement ( containingNonArrowFunction )
2825- && ! hasModifier ( containingNonArrowFunction , ModifierFlags . Static )
2832+ return superScopeContainer
2833+ && isClassElement ( superScopeContainer )
2834+ && ! hasModifier ( superScopeContainer , ModifierFlags . Static )
28262835 && currentParent . kind !== SyntaxKind . CallExpression
28272836 ? createPropertyAccess ( createIdentifier ( "_super" ) , "prototype" )
28282837 : createIdentifier ( "_super" ) ;
0 commit comments