Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
constantSuper
, superIsCallableConstructor
and `noClassC…
…alls` assumption (#12726) Co-authored-by: Justin Ridgewell <justin@ridgewell.name>
- Loading branch information
1 parent
f845446
commit d8392c3
Showing
37 changed files
with
465 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...babel-plugin-proposal-private-methods/test/fixtures/assumption-constantSuper/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"external-helpers", | ||
{ | ||
"helperVersion": "7.1000.0" | ||
} | ||
], | ||
"proposal-private-methods", | ||
"proposal-class-properties", | ||
"transform-block-scoping", | ||
"syntax-class-properties" | ||
], | ||
"assumptions": { | ||
"constantSuper": true | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...osal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Base { | ||
superMethod() { | ||
return 'good'; | ||
} | ||
} | ||
|
||
class Sub extends Base { | ||
superMethod() { | ||
return 'bad'; | ||
} | ||
|
||
#privateMethod() { | ||
return super.superMethod(); | ||
} | ||
|
||
publicMethod() { | ||
return this.#privateMethod(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...sal-private-methods/test/fixtures/assumption-constantSuper/private-method-super/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class Base { | ||
superMethod() { | ||
return 'good'; | ||
} | ||
|
||
} | ||
|
||
var _privateMethod = new WeakSet(); | ||
|
||
class Sub extends Base { | ||
constructor(...args) { | ||
super(...args); | ||
|
||
_privateMethod.add(this); | ||
} | ||
|
||
superMethod() { | ||
return 'bad'; | ||
} | ||
|
||
publicMethod() { | ||
return babelHelpers.classPrivateMethodGet(this, _privateMethod, _privateMethod2).call(this); | ||
} | ||
|
||
} | ||
|
||
var _privateMethod2 = function _privateMethod2() { | ||
return Base.prototype.superMethod.call(this); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...n-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Test extends Foo { | ||
constructor() { | ||
woops.super.test(); | ||
super(); | ||
super.test(); | ||
|
||
super(...arguments); | ||
super("test", ...arguments); | ||
|
||
super.test(...arguments); | ||
super.test("test", ...arguments); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...-transform-classes/test/fixtures/assumption-constantSuper/accessing-super-class/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var Test = /*#__PURE__*/function (_Foo) { | ||
"use strict"; | ||
|
||
babelHelpers.inherits(Test, _Foo); | ||
|
||
var _super = babelHelpers.createSuper(Test); | ||
|
||
function Test() { | ||
var _Foo$prototype$test; | ||
|
||
var _this; | ||
|
||
babelHelpers.classCallCheck(this, Test); | ||
woops.super.test(); | ||
_this = _super.call(this); | ||
|
||
_Foo.prototype.test.call(babelHelpers.assertThisInitialized(_this)); | ||
|
||
_this = _super.apply(this, arguments); | ||
_this = _super.call.apply(_super, [this, "test"].concat(Array.prototype.slice.call(arguments))); | ||
|
||
_Foo.prototype.test.apply(babelHelpers.assertThisInitialized(_this), arguments); | ||
|
||
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [babelHelpers.assertThisInitialized(_this), "test"].concat(Array.prototype.slice.call(arguments))); | ||
|
||
return _this; | ||
} | ||
|
||
return Test; | ||
}(Foo); |
7 changes: 7 additions & 0 deletions
7
...nsform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Test extends Foo { | ||
constructor() { | ||
super(); | ||
super.test; | ||
super.test.whatever; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...sform-classes/test/fixtures/assumption-constantSuper/accessing-super-properties/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var Test = /*#__PURE__*/function (_Foo) { | ||
"use strict"; | ||
|
||
babelHelpers.inherits(Test, _Foo); | ||
|
||
var _super = babelHelpers.createSuper(Test); | ||
|
||
function Test() { | ||
var _this; | ||
|
||
babelHelpers.classCallCheck(this, Test); | ||
_this = _super.call(this); | ||
_Foo.prototype.test; | ||
_Foo.prototype.test.whatever; | ||
return _this; | ||
} | ||
|
||
return Test; | ||
}(Foo); |
6 changes: 6 additions & 0 deletions
6
...s/test/fixtures/assumption-constantSuper/accessing-super-property-optional-chain/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Test extends Foo { | ||
constructor() { | ||
super.foo?.bar; | ||
super.foo?.(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...st/fixtures/assumption-constantSuper/accessing-super-property-optional-chain/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"plugins": [ | ||
["external-helpers", { "helperVersion": "7.100.0" }], | ||
["proposal-optional-chaining", { "loose": true }], | ||
"transform-function-name", | ||
["transform-classes", { "loose": true }], | ||
["transform-spread", { "loose": true }], | ||
"transform-block-scoping" | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
.../test/fixtures/assumption-constantSuper/accessing-super-property-optional-chain/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var Test = /*#__PURE__*/function (_Foo) { | ||
"use strict"; | ||
|
||
babelHelpers.inheritsLoose(Test, _Foo); | ||
|
||
function Test() { | ||
var _Foo$prototype$foo, _Foo$prototype$foo2; | ||
|
||
var _this; | ||
|
||
(_Foo$prototype$foo = _Foo.prototype.foo) == null ? void 0 : _Foo$prototype$foo.bar; | ||
(_Foo$prototype$foo2 = _Foo.prototype.foo) == null ? void 0 : _Foo$prototype$foo2.call(babelHelpers.assertThisInitialized(_this)); | ||
return babelHelpers.assertThisInitialized(_this); | ||
} | ||
|
||
return Test; | ||
}(Foo); |
11 changes: 11 additions & 0 deletions
11
...ransform-classes/test/fixtures/assumption-constantSuper/calling-super-properties/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Test extends Foo { | ||
constructor() { | ||
super(); | ||
super.test.whatever(); | ||
super.test(); | ||
} | ||
|
||
static test() { | ||
return super.wow(); | ||
} | ||
} |
Oops, something went wrong.