Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix super Method Calls in Class Private Methods #9704

Merged
merged 2 commits into from Mar 19, 2019

Conversation

tim-mc
Copy link
Contributor

@tim-mc tim-mc commented Mar 19, 2019

Q                       A
Fixed Issues? Fixes #9580
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
License MIT

This fixes an issue with the use of super method calls in class private methods. See #9580 for more info re: behavior of the bug.

@tim-mc
Copy link
Contributor Author

tim-mc commented Mar 19, 2019

@nicolo-ribaudo

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 19, 2019

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10522/

this.isStatic =
path.isClassMethod({ static: true }) || path.isObjectMethod();
this.isStatic = path.isObjectMethod() || path.node.static;
this.isPrivateMethod = path.isPrivate() && path.isMethod();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I would just add this as a new case to isStatic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept them separate because rolling isPrivateMethod into isStatic will cause an issue with the loose handler. If the path is an instance private method, this condition becomes truthy, and this output is instead transformed to:

var _privateMethod2 = function _privateMethod2() {
  return Base.superMethod.call(this);
};

@danez danez added PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Private Methods Spec: Class Fields and removed Spec: Private Methods labels Mar 19, 2019
@nicolo-ribaudo nicolo-ribaudo merged commit e068281 into babel:master Mar 19, 2019
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Class Fields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

super method calls do not work in private instance methods
5 participants