Merge pull request #10189 from chancancode/constructor-splat-arguments

Emit more efficient/concise "empty" ES6 ctor
This commit is contained in:
Daniel Rosenwasser 2016-08-16 15:39:11 -07:00 committed by GitHub
commit 9cc8b2ebb2
3 changed files with 8 additions and 19 deletions

View file

@ -5311,18 +5311,7 @@ const _super = (function (geti, seti) {
emitSignatureParameters(ctor);
}
else {
// Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation.
// If constructor is empty, then,
// If ClassHeritageopt is present, then
// Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition.
// Else,
// Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition
if (baseTypeElement) {
write("(...args)");
}
else {
write("()");
}
write("()");
}
}
@ -5360,7 +5349,7 @@ const _super = (function (geti, seti) {
write("_super.apply(this, arguments);");
}
else {
write("super(...args);");
write("super(...arguments);");
}
emitEnd(baseTypeElement);
}

View file

@ -13,14 +13,14 @@ let C = class extends class extends class {
}
}
{
constructor(...args) {
super(...args);
constructor() {
super(...arguments);
this.b = 2;
}
}
{
constructor(...args) {
super(...args);
constructor() {
super(...arguments);
this.c = 3;
}
}

View file

@ -37,8 +37,8 @@ class D {
}
}
class E extends D {
constructor(...args) {
super(...args);
constructor() {
super(...arguments);
this.z = true;
}
}