summaryrefslogtreecommitdiff
path: root/node_modules/@babel/helper-replace-supers/lib/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/helper-replace-supers/lib/index.js')
-rw-r--r--node_modules/@babel/helper-replace-supers/lib/index.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/node_modules/@babel/helper-replace-supers/lib/index.js b/node_modules/@babel/helper-replace-supers/lib/index.js
index d2a2a0e5..85878d1c 100644
--- a/node_modules/@babel/helper-replace-supers/lib/index.js
+++ b/node_modules/@babel/helper-replace-supers/lib/index.js
@@ -88,24 +88,18 @@ const specHandlers = {
},
_get(superMember, thisRefs) {
const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
- return callExpression(this.file.addHelper("get"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), thisRefs.this]);
+ return callExpression(this.file.addHelper("get"), [thisRefs.needAccessFirst ? sequenceExpression([thisRefs.this, proto]) : proto, this.prop(superMember), thisRefs.this]);
},
_getThisRefs() {
- if (!this.isDerivedConstructor) {
- return {
- this: thisExpression()
- };
- }
- const thisRef = this.scope.generateDeclaredUidIdentifier("thisSuper");
return {
- memo: assignmentExpression("=", thisRef, thisExpression()),
- this: cloneNode(thisRef)
+ needAccessFirst: this.isDerivedConstructor,
+ this: thisExpression()
};
},
set(superMember, value) {
const thisRefs = this._getThisRefs();
const proto = getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod);
- return callExpression(this.file.addHelper("set"), [thisRefs.memo ? sequenceExpression([thisRefs.memo, proto]) : proto, this.prop(superMember), value, thisRefs.this, booleanLiteral(superMember.isInStrictMode())]);
+ return callExpression(this.file.addHelper("set"), [thisRefs.needAccessFirst ? sequenceExpression([thisRefs.this, proto]) : proto, this.prop(superMember), value, thisRefs.this, booleanLiteral(superMember.isInStrictMode())]);
},
destructureSet(superMember) {
throw superMember.buildCodeFrameError(`Destructuring to a super field is not supported yet.`);
@@ -204,13 +198,23 @@ class ReplaceSupers {
}
}
replace() {
+ const {
+ methodPath
+ } = this;
if (this.opts.refToPreserve) {
- this.methodPath.traverse(unshadowSuperBindingVisitor, {
+ methodPath.traverse(unshadowSuperBindingVisitor, {
refName: this.opts.refToPreserve.name
});
}
const handler = this.constantSuper ? looseHandlers : specHandlers;
- (0, _helperMemberExpressionToFunctions.default)(this.methodPath, visitor, Object.assign({
+ visitor.shouldSkip = path => {
+ if (path.parentPath === methodPath) {
+ if (path.parentKey === "decorators" || path.parentKey === "key") {
+ return true;
+ }
+ }
+ };
+ (0, _helperMemberExpressionToFunctions.default)(methodPath, visitor, Object.assign({
file: this.file,
scope: this.methodPath.scope,
isDerivedConstructor: this.isDerivedConstructor,