[es6] Class extends may not be a generator function
BUG=v8:4009 LOG=N R=dslomov@chromium.org Review URL: https://codereview.chromium.org/1101543002 Cr-Commit-Position: refs/heads/master@{#28016}
This commit is contained in:
parent
ec542dea6b
commit
3f06291b3a
@ -157,6 +157,7 @@ var kMessages = {
|
|||||||
duplicate_export: ["Duplicate export of '", "%0", "'"],
|
duplicate_export: ["Duplicate export of '", "%0", "'"],
|
||||||
unexpected_super: ["'super' keyword unexpected here"],
|
unexpected_super: ["'super' keyword unexpected here"],
|
||||||
extends_value_not_a_function: ["Class extends value ", "%0", " is not a function or null"],
|
extends_value_not_a_function: ["Class extends value ", "%0", " is not a function or null"],
|
||||||
|
extends_value_generator: ["Class extends value ", "%0", " may not be a generator function"],
|
||||||
prototype_parent_not_an_object: ["Class extends value does not have valid prototype property ", "%0"],
|
prototype_parent_not_an_object: ["Class extends value does not have valid prototype property ", "%0"],
|
||||||
duplicate_constructor: ["A class may only have one constructor"],
|
duplicate_constructor: ["A class may only have one constructor"],
|
||||||
super_constructor_call: ["A 'super' constructor call may only appear as the first statement of a function, and its arguments may not access 'this'. Other forms are not yet supported."],
|
super_constructor_call: ["A 'super' constructor call may only appear as the first statement of a function, and its arguments may not access 'this'. Other forms are not yet supported."],
|
||||||
|
@ -119,6 +119,12 @@ RUNTIME_FUNCTION(Runtime_DefineClass) {
|
|||||||
if (super_class->IsNull()) {
|
if (super_class->IsNull()) {
|
||||||
prototype_parent = isolate->factory()->null_value();
|
prototype_parent = isolate->factory()->null_value();
|
||||||
} else if (super_class->IsSpecFunction()) {
|
} else if (super_class->IsSpecFunction()) {
|
||||||
|
if (Handle<JSFunction>::cast(super_class)->shared()->is_generator()) {
|
||||||
|
Handle<Object> args[1] = {super_class};
|
||||||
|
THROW_NEW_ERROR_RETURN_FAILURE(
|
||||||
|
isolate,
|
||||||
|
NewTypeError("extends_value_generator", HandleVector(args, 1)));
|
||||||
|
}
|
||||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||||
isolate, prototype_parent,
|
isolate, prototype_parent,
|
||||||
Runtime::GetObjectProperty(isolate, super_class,
|
Runtime::GetObjectProperty(isolate, super_class,
|
||||||
|
@ -71,6 +71,11 @@
|
|||||||
class C extends Math.abs {}
|
class C extends Math.abs {}
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
delete Math.abs.prototype;
|
delete Math.abs.prototype;
|
||||||
|
|
||||||
|
assertThrows(function() {
|
||||||
|
function* g() {}
|
||||||
|
class C extends g {}
|
||||||
|
}, TypeError);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user