add support for inheriting from statically inlined native constructors - closes #1172

This commit is contained in:
Sebastian McKenzie
2015-04-11 19:47:11 -07:00
parent 3561efdb86
commit 274a6e01dc
6 changed files with 118 additions and 5 deletions

View File

@@ -0,0 +1,10 @@
class Foo extends Array {
}
class Bar extends Array {
constructor() {
super();
this.foo = "bar";
}
}

View File

@@ -0,0 +1,27 @@
class Foo extends Array {
}
class Bar extends Array {
constructor() {
super();
this.foo = "bar";
}
}
var foo = new Foo;
assert.ok(Array.isArray(foo));
foo.push(1);
foo.push(2);
assert.equal(foo[0], 1);
assert.equal(foo[1], 2);
assert.equal(foo.length, 2);
var bar = new Bar;
assert.ok(Array.isArray(bar));
assert.equal(bar.foo, "bar");
bar.push(1);
bar.push(2);
assert.equal(bar[0], 1);
assert.equal(bar[1], 2);
assert.equal(bar.length, 2);

View File

@@ -0,0 +1,35 @@
"use strict";
var Foo = (function (_Array) {
function Foo() {
babelHelpers.classCallCheck(this, Foo);
if (_Array != null) {
var _this = new (babelHelpers.bind.apply(_Array, [null].concat(babelHelpers.slice.call(arguments))))();
_this.__proto__ = Foo.prototype;
return _this;
}
return _this;
}
babelHelpers.inherits(Foo, _Array);
return Foo;
})(Array);
var Bar = (function (_Array2) {
function Bar() {
babelHelpers.classCallCheck(this, Bar);
var _this2 = new _Array2();
_this2.__proto__ = Bar.prototype;
_this2.foo = "bar";
return _this2;
}
babelHelpers.inherits(Bar, _Array2);
return Bar;
})(Array);