Disallow duplicated AST nodes (#11807)

This commit is contained in:
Huáng Jùnliàng
2020-07-14 09:32:16 -04:00
committed by GitHub
parent ffb42488ba
commit 5dd64ecc4a
24 changed files with 85 additions and 62 deletions

View File

@@ -137,7 +137,7 @@ export function buildDecoratedClass(ref, path, elements, file) {
let replacement = template.expression.ast`
${addDecorateHelper(file)}(
${classDecorators || t.nullLiteral()},
function (${initializeId}, ${superClass ? superId : null}) {
function (${initializeId}, ${superClass ? t.cloneNode(superId) : null}) {
${node}
return { F: ${t.cloneNode(node.id)}, d: ${definitions} };
},
@@ -158,7 +158,7 @@ export function buildDecoratedClass(ref, path, elements, file) {
}
return {
instanceNodes: [template.statement.ast`${initializeId}(this)`],
instanceNodes: [template.statement.ast`${t.cloneNode(initializeId)}(this)`],
wrapClass(path) {
path.replaceWith(replacement);
return path.get(classPathDesc);