rewrite this in shadowed functions inside native derived class constructors - fixes #1340

This commit is contained in:
Sebastian McKenzie
2015-04-24 11:20:29 +01:00
parent 74f04ed6a1
commit a36c1b4a92
3 changed files with 45 additions and 0 deletions

View File

@@ -37,6 +37,22 @@ var collectPropertyReferencesVisitor = {
}
};
var constructorVisitor = traverse.explode({
ThisExpression: {
enter(node, parent, scope, ref) {
return ref;
}
},
Function: {
enter(node) {
if (!node.shadow) {
this.skip();
}
}
}
});
var verifyConstructorVisitor = traverse.explode({
MethodDefinition: {
enter() {
@@ -581,6 +597,10 @@ class ClassTransformer {
fnPath.scope.rename(this.classRef.name);
}
if (this.isNativeSuper) {
fnPath.traverse(constructorVisitor, this.nativeSuperRef);
}
var construct = this.constructor;
var fn = method.value;

View File

@@ -8,3 +8,10 @@ class Bar extends Array {
this.foo = "bar";
}
}
class Baz extends Array {
constructor() {
super();
(() => this)
}
}

View File

@@ -33,3 +33,21 @@ var Bar = (function (_Array2) {
babelHelpers.inherits(Bar, _Array2);
return Bar;
})(Array);
var Baz = (function (_Array3) {
function Baz() {
babelHelpers.classCallCheck(this, Baz);
var _this3 = new _Array3();
_this3.__proto__ = Baz.prototype;
(function () {
return _this3;
});
return _this3;
}
babelHelpers.inherits(Baz, _Array3);
return Baz;
})(Array);