mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-15 08:53:07 +09:00
Issue #2142 - Pass through arguments in synthesized constructors for derived classes
Based-on: m-c 1552022
This commit is contained in:
parent
bcb6203e4f
commit
1031b1fc43
2 changed files with 27 additions and 2 deletions
|
|
@ -7845,9 +7845,22 @@ Parser<ParseHandler>::synthesizeConstructor(HandleAtom className, uint32_t class
|
|||
if (!argsbody)
|
||||
return null();
|
||||
handler.setFunctionFormalParametersAndBody(funNode, argsbody);
|
||||
funbox->function()->setArgCount(0);
|
||||
funbox->setStart(tokenStream);
|
||||
|
||||
if (hasHeritage) {
|
||||
// Synthesize the equivalent to `function f(...args)`
|
||||
funbox->setHasRest();
|
||||
if (!notePositionalFormalParameter(funNode, context->names().args,
|
||||
synthesizedBodyPos.begin,
|
||||
/* disallowDuplicateParams = */ false,
|
||||
/* duplicatedParam = */ nullptr)) {
|
||||
return null();
|
||||
}
|
||||
funbox->function()->setArgCount(1);
|
||||
} else {
|
||||
funbox->function()->setArgCount(0);
|
||||
}
|
||||
|
||||
pc->functionScope().useAsVarScope(pc);
|
||||
|
||||
auto stmtList = handler.newStatementList(synthesizedBodyPos);
|
||||
|
|
@ -7881,7 +7894,18 @@ Parser<ParseHandler>::synthesizeConstructor(HandleAtom className, uint32_t class
|
|||
if (!arguments)
|
||||
return null();
|
||||
|
||||
BinaryNodeType superCall = handler.newSuperCall(superBase, arguments, false);
|
||||
NameNodeType argsNameNode = newName(context->names().args, synthesizedBodyPos);
|
||||
if (!argsNameNode)
|
||||
return null();
|
||||
if (!noteUsedName(context->names().args))
|
||||
return null();
|
||||
|
||||
UnaryNodeType spreadArgs = handler.newSpread(synthesizedBodyPos.begin, argsNameNode);
|
||||
if (!spreadArgs)
|
||||
return null();
|
||||
handler.addList(arguments, spreadArgs);
|
||||
|
||||
BinaryNodeType superCall = handler.newSuperCall(superBase, arguments, /* isSpread = */ true);
|
||||
if (!superCall)
|
||||
return null();
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
macro(anonymous, anonymous, "anonymous") \
|
||||
macro(Any, Any, "Any") \
|
||||
macro(apply, apply, "apply") \
|
||||
macro(args, args, "args") \
|
||||
macro(arguments, arguments, "arguments") \
|
||||
macro(ArrayBufferSpecies, ArrayBufferSpecies, "ArrayBufferSpecies") \
|
||||
macro(ArrayIterator, ArrayIterator, "Array Iterator") \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue