}
+void ATAV::VisitSuperReference(SuperReference* leaf) {
+ // disallow super.method() and super(...).
+ uses_this_ = true;
+}
+
+
+void ATAV::VisitCallNew(CallNew* e) {
+ // new super(..) does not use 'this'.
+ if (!e->expression()->IsSuperReference()) {
+ Visit(e->expression());
+ }
+ VisitExpressions(e->arguments());
+}
+
+
// ---------------------------------------------------------------------------
// -- Leaf nodes -------------------------------------------------------------
// ---------------------------------------------------------------------------
void ATAV::VisitLiteral(Literal* leaf) {}
void ATAV::VisitRegExpLiteral(RegExpLiteral* leaf) {}
void ATAV::VisitThisFunction(ThisFunction* leaf) {}
-void ATAV::VisitSuperReference(SuperReference* leaf) {}
-
// ---------------------------------------------------------------------------
// -- Pass-through nodes------------------------------------------------------
void ATAV::VisitClassLiteral(ClassLiteral* e) {
VisitIfNotNull(e->extends());
- VisitIfNotNull(e->constructor());
+ Visit(e->constructor());
ZoneList<ObjectLiteralProperty*>* properties = e->properties();
for (int i = 0; i < properties->length(); i++) {
Visit(properties->at(i)->value());
}
-void ATAV::VisitCallNew(CallNew* e) {
- Visit(e->expression());
- VisitExpressions(e->arguments());
-}
-
-
void ATAV::VisitCallRuntime(CallRuntime* e) {
VisitExpressions(e->arguments());
}
if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
if (scope_uses_super_property_)
Indent(n1, "// scope uses 'super' property\n");
- if (scope_uses_super_constructor_call_) {
+ if (scope_uses_super_constructor_call_)
Indent(n1, "// scope uses 'super' constructor\n");
- }
if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n");
if (inner_scope_uses_arguments_) {
Indent(n1, "// inner scope uses 'arguments'\n");
assertThrows(function() {
class C {
constructor() {
+ super.method();
+ super(this);
+ }
+ }; new C();
+ }, TypeError);
+ assertThrows(function() {
+ class C {
+ constructor() {
+ super(super.method());
+ }
+ }; new C();
+ }, TypeError);
+ assertThrows(function() {
+ class C {
+ constructor() {
+ super(super());
+ }
+ }; new C();
+ }, TypeError);
+ assertThrows(function() {
+ class C {
+ constructor() {
super(1, 2, Object.getPrototypeOf(this));
}
}; new C();
}
};
new C3();
+
+ class C4 extends Object {
+ constructor() {
+ super(new super());
+ }
+ }; new C4();
}());