@@ -10,6 +10,7 @@ namespace ts {
10
10
/** Enables substitutions for block-scoped bindings. */
11
11
BlockScopedBindings = 1 << 1 ,
12
12
}
13
+
13
14
/**
14
15
* If loop contains block scoped binding captured in some function then loop body is converted to a function.
15
16
* Lexical bindings declared in loop initializer will be passed into the loop body function as parameters,
@@ -166,6 +167,9 @@ namespace ts {
166
167
let enclosingBlockScopeContainerParent : Node ;
167
168
let containingNonArrowFunction : FunctionLikeDeclaration | ClassElement ;
168
169
170
+ /** Tracks the container that determines whether `super.x` is a static. */
171
+ let superScopeContainer : FunctionLikeDeclaration | ClassElement ;
172
+
169
173
/**
170
174
* Used to track if we are emitting body of the converted loop
171
175
*/
@@ -203,6 +207,7 @@ namespace ts {
203
207
204
208
function saveStateAndInvoke < T > ( node : Node , f : ( node : Node ) => T ) : T {
205
209
const savedContainingNonArrowFunction = containingNonArrowFunction ;
210
+ const savedSuperScopeContainer = superScopeContainer ;
206
211
const savedCurrentParent = currentParent ;
207
212
const savedCurrentNode = currentNode ;
208
213
const savedEnclosingBlockScopeContainer = enclosingBlockScopeContainer ;
@@ -219,6 +224,7 @@ namespace ts {
219
224
220
225
convertedLoopState = savedConvertedLoopState ;
221
226
containingNonArrowFunction = savedContainingNonArrowFunction ;
227
+ superScopeContainer = savedSuperScopeContainer ;
222
228
currentParent = savedCurrentParent ;
223
229
currentNode = savedCurrentNode ;
224
230
enclosingBlockScopeContainer = savedEnclosingBlockScopeContainer ;
@@ -414,13 +420,16 @@ namespace ts {
414
420
}
415
421
416
422
switch ( currentParent . kind ) {
423
+ case SyntaxKind . FunctionExpression :
417
424
case SyntaxKind . Constructor :
418
425
case SyntaxKind . MethodDeclaration :
419
426
case SyntaxKind . GetAccessor :
420
427
case SyntaxKind . SetAccessor :
421
428
case SyntaxKind . FunctionDeclaration :
422
- case SyntaxKind . FunctionExpression :
423
429
containingNonArrowFunction = < FunctionLikeDeclaration > currentParent ;
430
+ if ( ! ( containingNonArrowFunction . emitFlags & NodeEmitFlags . AsyncFunctionBody ) ) {
431
+ superScopeContainer = containingNonArrowFunction ;
432
+ }
424
433
break ;
425
434
}
426
435
}
@@ -2820,9 +2829,9 @@ namespace ts {
2820
2829
* Visits the `super` keyword
2821
2830
*/
2822
2831
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 )
2826
2835
&& currentParent . kind !== SyntaxKind . CallExpression
2827
2836
? createPropertyAccess ( createIdentifier ( "_super" ) , "prototype" )
2828
2837
: createIdentifier ( "_super" ) ;
0 commit comments