Fix default class super inheritance (#7732)

Fixes #7683.
This commit is contained in:
Justin Ridgewell
2018-04-14 15:15:40 -04:00
committed by GitHub
parent 858a2c74e7
commit 0ee9a4e612
8 changed files with 118 additions and 4 deletions

View File

@@ -0,0 +1,17 @@
class Test {
constructor() {
return super.constructor;
}
static test() {
return super.constructor;
}
}
// Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object);
// Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);

View File

@@ -0,0 +1,17 @@
class Test {
constructor() {
return super.constructor;
}
static test() {
return super.constructor;
}
}
// Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object);
// Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);

View File

@@ -0,0 +1,22 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
return Object.prototype.constructor;
}
Test.test = function test() {
return Function.prototype.constructor;
};
return Test;
}(); // Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object); // Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);

View File

@@ -1,5 +1,5 @@
var Test = function Test() {
"use strict";
Function.prototype.hasOwnProperty.call(this, "test");
Object.prototype.hasOwnProperty.call(this, "test");
};

View File

@@ -0,0 +1,17 @@
class Test {
constructor() {
return super.constructor;
}
static test() {
return super.constructor;
}
}
// Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object);
// Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);

View File

@@ -0,0 +1,17 @@
class Test {
constructor() {
return super.constructor;
}
static test() {
return super.constructor;
}
}
// Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object);
// Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);

View File

@@ -0,0 +1,25 @@
var Test =
/*#__PURE__*/
function () {
"use strict";
function Test() {
babelHelpers.classCallCheck(this, Test);
return babelHelpers.get(babelHelpers.getPrototypeOf(Test.prototype), "constructor", babelHelpers.assertThisInitialized(this));
}
babelHelpers.createClass(Test, null, [{
key: "test",
value: function test() {
return babelHelpers.get(babelHelpers.getPrototypeOf(Test), "constructor", this);
}
}]);
return Test;
}(); // Instances
expect(Object.getPrototypeOf(Test.prototype)).toBe(Object.prototype);
expect(new Test()).toBe(Object); // Static
expect(Object.getPrototypeOf(Test)).toBe(Function.prototype);
expect(Test.test()).toBe(Function);