fix error when constructor default arg refers to own static property or self (#4666)

(closes #4253)
(closes #4442)
This commit is contained in:
Dan Harper
2016-10-05 22:52:42 +01:00
committed by Henry Zhu
parent 6cfd3d91b2
commit 33eb56ab09
7 changed files with 63 additions and 3 deletions

View File

@@ -0,0 +1,6 @@
class Ref {
constructor(id = ++Ref.nextID) {
this.id = id
}
}
Ref.nextID = 0

View File

@@ -0,0 +1,9 @@
class Ref {
static nextId = 0
constructor(id = ++Ref.nextId, n = id) {
this.id = n
}
}
assert.equal(1, new Ref().id)
assert.equal(2, new Ref().id)

View File

@@ -0,0 +1,8 @@
var Ref = function Ref() {
var id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ++Ref.nextID;
babelHelpers.classCallCheck(this, Ref);
this.id = id;
};
Ref.nextID = 0;

View File

@@ -0,0 +1,11 @@
class Ref {
constructor(ref = Ref) {
this.ref = ref
}
}
class X {
constructor(x = foo) {
this.x = x
}
}

View File

@@ -0,0 +1,7 @@
class Ref {
constructor(ref = Ref) {
this.ref = ref
}
}
assert.equal(Ref, new Ref().ref)

View File

@@ -0,0 +1,13 @@
var Ref = function Ref() {
var ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Ref;
babelHelpers.classCallCheck(this, Ref);
this.ref = ref;
};
var X = function X() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : foo;
babelHelpers.classCallCheck(this, X);
this.x = x;
};