forced closure on super classes - fixes #339

This commit is contained in:
Sebastian McKenzie
2015-01-02 01:59:42 +11:00
parent 9529f93690
commit b1d1909c64
7 changed files with 95 additions and 64 deletions

View File

@@ -21,7 +21,7 @@ exports.ClassDeclaration = function (node, parent, file, scope) {
});
return t.assignmentExpression("=", node.id, newNode);
} else {
// likely has a PrivateDeclaration etc
// has a super class or PrivateDeclaration etc
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, newNode)
]);
@@ -85,7 +85,8 @@ Class.prototype.run = function () {
//
if (superName && t.isDynamic(superName)) {
if (superName) {
this.closure = true;
// so we're only evaluating it once
var superRefName = "super";
if (className) superRefName = className.name + "Super";
@@ -95,13 +96,8 @@ Class.prototype.run = function () {
t.variableDeclarator(superRef, superName)
]));
superName = superRef;
}
this.superName = superName;
//
if (superName) {
this.superName = superName;
body.push(t.expressionStatement(t.callExpression(file.addDeclaration("inherits"), [className, superName])));
}