Merge pull request #331 from Microsoft/capture_this_in_constructors

emit this capturing as a first action in the constructor.
This commit is contained in:
Vladimir Matveev
2014-08-01 11:33:09 -07:00
10 changed files with 51 additions and 11 deletions

View File

@@ -1371,6 +1371,7 @@ module ts {
write(" {");
scopeEmitStart(node, "constructor");
increaseIndent();
emitCaptureThisForNodeIfNecessary(node);
if (ctor) {
emitDefaultValueAssignments(ctor);
emitRestParameter(ctor);
@@ -1390,8 +1391,7 @@ module ts {
write("_super.apply(this, arguments);");
emitEnd(node.baseType);
}
}
emitCaptureThisForNodeIfNecessary(node);
}
emitMemberAssignments(node, /*nonstatic*/0);
if (ctor) {
var statements: Node[] = (<Block>ctor.body).statements;