From 11bc6c470f5dd09dc83fbf8ac269f0c8bc023ad0 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 3 Sep 2016 00:16:43 -0700 Subject: [PATCH] Fixed issue where last function context & parent node wasn't being preserved. This came up when a `super()` call was nested in another constructor body. Current logic in the transform says that if the last containing non-arrow function body is non-static, and the current parent isn't a call expression, the call target of a `super` call will become `_super.prototype` instead of `super`. If the state is not saved, the containing arrow function and parent are not saved, and the information for this check won't be accurate. --- src/compiler/transformers/es6.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index 9b703e5ddc4..85838112fc3 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -1143,9 +1143,10 @@ namespace ts { firstStatement = ctor.body.statements[firstNonPrologue]; if (firstStatement.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((firstStatement as ExpressionStatement).expression)) { + const superCall = (firstStatement as ExpressionStatement).expression as CallExpression; initializer = setOriginalNode( - visitImmediateSuperCallInBody(((firstStatement as ExpressionStatement).expression as CallExpression)), - (firstStatement as ExpressionStatement).expression + saveStateAndInvoke(superCall, visitImmediateSuperCallInBody), + superCall ); } }