Fix super Method Calls in Class Private Methods (#9704)

This fixes an issue with the use of super method calls in class private methods. See https://github.com/babel/babel/issues/9580 for more info re: behavior of the bug.
This commit is contained in:
Tim McClure
2019-03-19 13:43:02 -04:00
committed by Nicolò Ribaudo
parent 48d66eb648
commit e068281e28
8 changed files with 137 additions and 11 deletions

View File

@@ -501,10 +501,9 @@ function replaceThisContext(path, ref, superRef, file, loose) {
file,
getObjectRef() {
state.needsClassRef = true;
return ref;
return path.node.static ? ref : t.thisExpression();
},
});
replacer.isStatic = true;
replacer.replace();
if (path.isProperty()) {
path.traverse(thisContextVisitor, state);
@@ -532,7 +531,7 @@ export function buildFieldsInitNodes(
const isField = prop.isProperty();
const isMethod = !isField;
if (isStatic) {
if (isStatic || (isMethod && isPrivate)) {
const replaced = replaceThisContext(prop, ref, superRef, state, loose);
needsClassRef = needsClassRef || replaced;
}