Merge pull request #5802 from babel/issue5371
Remove check for super calls in arrow function
This commit is contained in:
commit
7e739f954d
@ -28,7 +28,11 @@ const verifyConstructorVisitor = visitors.merge([noMethodVisitor, {
|
||||
this.isDerived && !this.hasBareSuper &&
|
||||
!path.parentPath.isCallExpression({ callee: path.node })
|
||||
) {
|
||||
throw path.buildCodeFrameError("'super.*' is not allowed before super()");
|
||||
const hasArrowFunctionParent = path.findParent((p) => p.isArrowFunctionExpression());
|
||||
|
||||
if (!hasArrowFunctionParent) {
|
||||
throw path.buildCodeFrameError("'super.*' is not allowed before super()");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
const t = () => super.test()
|
||||
super.foo();
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "'super.*' is not allowed before super()"
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
class Foo extends Bar {
|
||||
constructor() {
|
||||
const t = () => super.test()
|
||||
super();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
var Foo = function (_Bar) {
|
||||
babelHelpers.inherits(Foo, _Bar);
|
||||
|
||||
function Foo() {
|
||||
var _this;
|
||||
|
||||
babelHelpers.classCallCheck(this, Foo);
|
||||
|
||||
var t = () => babelHelpers.get(Foo.prototype.__proto__ || Object.getPrototypeOf(Foo.prototype), "test", _this).call(_this);
|
||||
return _this = babelHelpers.possibleConstructorReturn(this, (Foo.__proto__ || Object.getPrototypeOf(Foo)).call(this));
|
||||
}
|
||||
|
||||
return Foo;
|
||||
}(Bar);
|
||||
Loading…
x
Reference in New Issue
Block a user