Validate ES6 'super' check is incorrect
I have a project written using ES6. In it, I call super as in this example:
class A {
toString() {
return 'A';
}
}
class B extends A {
toString() {
return super().replace(/A/g, 'B');
}
}
This should be fine, with B#toString calling A#toString by calling super(). However, WebStorm interprets super() in this context as a call to the constructor function. In the current ES6 spec under the super keyword section, you can see that using it as the callee in a CallExpression calls the JS internal method MakeSuperReference(undefined, strict). In step 7 of MakeSuperReference says that if the property key is undefined that it should be set by looking up the method name of the method containing the super call. Therefore, a naked call to super() in a method that is not the constructor should be allowed and interpreted as a call to the method on the superclass with the same name as the containing method.
Is there somewhere I should file this as a bug, or will this suffice?
Please sign in to leave a comment.
Logged as http://youtrack.jetbrains.com/issue/WEB-12317, please vote for it