Correctly access shadowed class binding in super.* (#12544)

* rename own binding inside methods if it collides with class ref. fix #11994

* fix name collisions in constructor

* do fix name collisions in constructor

* move logic in ReplaceSupers

* fix tests of helper-create-class-features-plugin

* remove replaceSupers in pushConstructor

* use environmentVisitor

* skip classLike nodes

* fix super ref in computed key
This commit is contained in:
Zen
2021-01-12 09:31:06 +08:00
committed by GitHub
parent 4f83a09dd8
commit cba64f9a09
13 changed files with 253 additions and 5 deletions

View File

@@ -174,6 +174,7 @@ export default function transformClass(
superRef: classState.superName,
isLoose: classState.isLoose,
file: classState.file,
refToPreserve: classState.classRef,
});
replaceSupers.replace();
@@ -496,11 +497,6 @@ export default function transformClass(
method: { type: "ClassMethod" },
path: NodePath,
) {
// https://github.com/babel/babel/issues/1077
if (path.scope.hasOwnBinding(classState.classRef.name)) {
path.scope.rename(classState.classRef.name);
}
setState({
userConstructorPath: path,
userConstructor: method,