make bare super call in non-constructors illegal
This commit is contained in:
@@ -202,6 +202,14 @@ ReplaceSupers.prototype.specHandle = function (getThisReference, node, parent) {
|
||||
throw this.file.errorWithNode(node, "illegal use of bare super");
|
||||
}
|
||||
} else if (t.isCallExpression(node)) {
|
||||
// super(); is illegal inside non-constructors
|
||||
// https://esdiscuss.org/topic/super-call-in-methods
|
||||
// https://twitter.com/wycats/status/544553184396836864
|
||||
if (methodNode.key.name !== "constructor") {
|
||||
var methodName = methodNode.key.name || "METHOD_NAME";
|
||||
throw this.file.errorWithNode(node, "Direct super call is illegal in non-constructor, use super." + methodName + "() instead");
|
||||
}
|
||||
|
||||
var callee = node.callee;
|
||||
if (t.isIdentifier(callee, { name: "super" })) {
|
||||
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
|
||||
|
||||
Reference in New Issue
Block a user