Skip to content

Commit

Permalink
Fix compilation of nested super(...) calls (#14709)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbacarel committed Jul 1, 2022
1 parent 2bbcd1e commit 3c14351
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/babel-plugin-transform-classes/src/transformClass.ts
Expand Up @@ -399,22 +399,22 @@ export default function transformClass(
);
}

const bareSupers = new Set<NodePath<t.CallExpression>>();
const bareSupers: NodePath<t.CallExpression>[] = [];
path.traverse(
traverse.visitors.merge([
environmentVisitor,
{
Super(path) {
const { node, parentPath } = path;
if (parentPath.isCallExpression({ callee: node })) {
bareSupers.add(parentPath);
bareSupers.unshift(parentPath);
}
},
} as Visitor,
]),
);

let guaranteedSuperBeforeFinish = !!bareSupers.size;
let guaranteedSuperBeforeFinish = !!bareSupers.length;

for (const bareSuper of bareSupers) {
wrapSuperCall(bareSuper, classState.superName, thisRef, body);
Expand Down
@@ -0,0 +1,5 @@
class C extends P {
constructor() {
super(super(super()))
}
}
@@ -0,0 +1,16 @@
var C = /*#__PURE__*/function (_P) {
"use strict";

babelHelpers.inherits(C, _P);

var _super = babelHelpers.createSuper(C);

function C() {
var _this;

babelHelpers.classCallCheck(this, C);
return _super.call(this, _this = _super.call(this, _this = _super.call(this)));
}

return babelHelpers.createClass(C);
}(P);

0 comments on commit 3c14351

Please sign in to comment.